You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "arturobernalg (via GitHub)" <gi...@apache.org> on 2025/10/12 09:38:35 UTC

[PR] Use reflection for Commons Compress codecs to avoid hard dep. [httpcomponents-client]

arturobernalg opened a new pull request, #737:
URL: https://github.com/apache/httpcomponents-client/pull/737

   Refactor codec integration to load Commons Compress via reflection. This removes compile-time references, respects the optional dependency, and eliminates `ExceptionInInitializerError` when the library is missing. `runtimeAvailable()` now probes Commons Compress algorithm classes 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: [PR] Use reflection for Commons Compress codecs to avoid hard dep. [httpcomponents-client]

Posted by "ok2c (via GitHub)" <gi...@apache.org>.
ok2c commented on PR #737:
URL: https://github.com/apache/httpcomponents-client/pull/737#issuecomment-3394173501

   @arturobernalg OK. As a first step please do this. Make `CommonsCompressingEntity` work the same way as `DecompressingEntity` and use  `IOFunction<OutputStream, OutputStream> encoder as an injectable dependency. Extract reflective code from `CompressingEntity` to `CommonsCompressDecoderFactory`. Rename `CommonsCompressingEntity` to `CompressingEntity`.  Rename `CommonsCompressDecoderFactory` to `CommonsCompressCodecFactory`.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: [PR] Use reflection for Commons Compress codecs to avoid hard dep. [httpcomponents-client]

Posted by "rschmitt (via GitHub)" <gi...@apache.org>.
rschmitt commented on code in PR #737:
URL: https://github.com/apache/httpcomponents-client/pull/737#discussion_r2426926646


##########
httpclient5/pom.xml:
##########
@@ -77,11 +77,6 @@
       <artifactId>log4j-core</artifactId>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>org.brotli</groupId>
-      <artifactId>dec</artifactId>
-      <optional>true</optional>
-    </dependency>

Review Comment:
   I'm confused. Why has this dependency declaration been removed? There are still (reflective) usages of these classes in the library:
   
   ```
   httpclient5/src/main/java/org/apache/hc/client5/http/entity/BrotliDecompressingEntity.java
   52:            Class.forName("org.brotli.dec.BrotliInputStream");
   
   httpclient5/src/main/java/org/apache/hc/client5/http/entity/compress/CommonsCompressCodecFactory.java
   76:    private static final String H_BROTLI = "org.brotli.dec.BrotliInputStream";
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: [PR] Use reflection for Commons Compress codecs to avoid hard dep. [httpcomponents-client]

Posted by "ok2c (via GitHub)" <gi...@apache.org>.
ok2c commented on code in PR #737:
URL: https://github.com/apache/httpcomponents-client/pull/737#discussion_r2428208096


##########
httpclient5/pom.xml:
##########
@@ -77,11 +77,6 @@
       <artifactId>log4j-core</artifactId>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>org.brotli</groupId>
-      <artifactId>dec</artifactId>
-      <optional>true</optional>
-    </dependency>

Review Comment:
   @rschmitt I asked @arturobernalg to move brotli related changes to a separate change-set. This must have contributed to the confusion.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: [PR] Use reflection for Commons Compress codecs to avoid hard dep. [httpcomponents-client]

Posted by "arturobernalg (via GitHub)" <gi...@apache.org>.
arturobernalg commented on PR #737:
URL: https://github.com/apache/httpcomponents-client/pull/737#issuecomment-3394762175

   > @arturobernalg OK. As a first step please do the following. Make `CommonsCompressingEntity` work the same way as `DecompressingEntity` and take `IOFunction<OutputStream, OutputStream>` encoder as an injectable dependency. Extract reflective code from `CompressingEntity` to `CommonsCompressDecoderFactory`. Rename `CommonsCompressingEntity` to `CompressingEntity`. Rename `CommonsCompressDecoderFactory` to `CommonsCompressCodecFactory`.
   
   @ok2c  I just Replaced Commons Compress with brotli4j for both encode and decode in the async round-trip example.  Please let me now if is what you was thinking 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: [PR] Use reflection for Commons Compress codecs to avoid hard dep. [httpcomponents-client]

Posted by "ok2c (via GitHub)" <gi...@apache.org>.
ok2c commented on PR #737:
URL: https://github.com/apache/httpcomponents-client/pull/737#issuecomment-3394814533

   @arturobernalg This is much, much better in my opinion .I just do not like that two distinct changes got mixed up in a single change-set. Would it be a big deal for you to spin Brotli related changes into a separate pull request? 
   
   Some javadocs (`CompressingEntity` for instance) also are no longer in sync with the code. This should be revised.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: [PR] Use reflection for Commons Compress codecs to avoid hard dep. [httpcomponents-client]

Posted by "arturobernalg (via GitHub)" <gi...@apache.org>.
arturobernalg merged PR #737:
URL: https://github.com/apache/httpcomponents-client/pull/737


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: [PR] Use reflection for Commons Compress codecs to avoid hard dep. [httpcomponents-client]

Posted by "ok2c (via GitHub)" <gi...@apache.org>.
ok2c commented on code in PR #737:
URL: https://github.com/apache/httpcomponents-client/pull/737#discussion_r2424887448


##########
httpclient5/src/main/java/org/apache/hc/client5/http/entity/compress/ContentCodecRegistry.java:
##########
@@ -62,15 +73,14 @@ private static Map<ContentCoding, Codec> build() {
 
         m.put(ContentCoding.GZIP,
                 new Codec(
-                        // encoder
                         org.apache.hc.client5.http.entity.GzipCompressingEntity::new,

Review Comment:
   @arturobernalg There is no need to use a fully qualified class name. It can be imported



##########
httpclient5/src/main/java/org/apache/hc/client5/http/entity/compress/ContentCodecRegistry.java:
##########
@@ -62,15 +73,14 @@ private static Map<ContentCoding, Codec> build() {
 
         m.put(ContentCoding.GZIP,
                 new Codec(
-                        // encoder
                         org.apache.hc.client5.http.entity.GzipCompressingEntity::new,
                         ent -> new DecompressingEntity(ent, GZIPInputStream::new)));
         m.put(ContentCoding.DEFLATE,
                 new Codec(
                         org.apache.hc.client5.http.entity.DeflateCompressingEntity::new,

Review Comment:
   @arturobernalg Same.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: [PR] Use reflection for Commons Compress codecs to avoid hard dep. [httpcomponents-client]

Posted by "ok2c (via GitHub)" <gi...@apache.org>.
ok2c commented on code in PR #737:
URL: https://github.com/apache/httpcomponents-client/pull/737#discussion_r2428412979


##########
httpclient5/pom.xml:
##########
@@ -77,11 +77,6 @@
       <artifactId>log4j-core</artifactId>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>org.brotli</groupId>
-      <artifactId>dec</artifactId>
-      <optional>true</optional>
-    </dependency>

Review Comment:
   @arturobernalg @rschmitt I would like to revert some of reflective calls in `CommonsCompressCodecFactory` that are not necessary if `ContentCodecRegistry` works correctly and does not call any of `CommonsCompressCodecFactory` methods at runtime if Commons Compress is not present.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: [PR] Use reflection for Commons Compress codecs to avoid hard dep. [httpcomponents-client]

Posted by "arturobernalg (via GitHub)" <gi...@apache.org>.
arturobernalg commented on code in PR #737:
URL: https://github.com/apache/httpcomponents-client/pull/737#discussion_r2428053248


##########
httpclient5/pom.xml:
##########
@@ -77,11 +77,6 @@
       <artifactId>log4j-core</artifactId>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>org.brotli</groupId>
-      <artifactId>dec</artifactId>
-      <optional>true</optional>
-    </dependency>

Review Comment:
   Please @rschmitt  take a look to this PR  [738](https://github.com/apache/httpcomponents-client/pull/738) where everything is tackle  



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: [PR] Use reflection for Commons Compress codecs to avoid hard dep. [httpcomponents-client]

Posted by "arturobernalg (via GitHub)" <gi...@apache.org>.
arturobernalg commented on PR #737:
URL: https://github.com/apache/httpcomponents-client/pull/737#issuecomment-3394956133

   > @arturobernalg This is much, much better in my opinion .I just do not like that two distinct changes got mixed up in a single change-set. Would it be a big deal for you to spin Brotli related changes into a separate pull request?
   > 
   > Some javadocs (`CompressingEntity` for instance) also are no longer in sync with the code. This should be revised.
   
   @Fixed. I'm separating the PR in two. Another one is coming with the only reflection on Brotli


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: [PR] Use reflection for Commons Compress codecs to avoid hard dep. [httpcomponents-client]

Posted by "ok2c (via GitHub)" <gi...@apache.org>.
ok2c commented on code in PR #737:
URL: https://github.com/apache/httpcomponents-client/pull/737#discussion_r2428412979


##########
httpclient5/pom.xml:
##########
@@ -77,11 +77,6 @@
       <artifactId>log4j-core</artifactId>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>org.brotli</groupId>
-      <artifactId>dec</artifactId>
-      <optional>true</optional>
-    </dependency>

Review Comment:
   @arturobernalg @rschmitt I would like to revert some of reflective calls in `CommonsCompressCodecFactory`. They are unnecessary if `ContentCodecRegistry` works correctly and does not call any of `CommonsCompressCodecFactory` methods at runtime if Commons Compress is not present.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: [PR] Use reflection for Commons Compress codecs to avoid hard dep. [httpcomponents-client]

Posted by "ok2c (via GitHub)" <gi...@apache.org>.
ok2c commented on PR #737:
URL: https://github.com/apache/httpcomponents-client/pull/737#issuecomment-3394146524

   @arturobernalg Why is `CommonsCompressingEntity` using reflection? I do not think it should be. So should not be `CommonsCompressDecoderFactory`. The only class making use of reflection should `CommonsCompressSupport` if everything has been properly designed. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Re: [PR] Use reflection for Commons Compress codecs to avoid hard dep. [httpcomponents-client]

Posted by "ok2c (via GitHub)" <gi...@apache.org>.
ok2c commented on PR #737:
URL: https://github.com/apache/httpcomponents-client/pull/737#issuecomment-3394149223

   @arturobernalg Please sort out the problem with multiple "brotli" dependencies.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org