garydgregory commented on PR #629:
URL: https://github.com/apache/commons-compress/pull/629#issuecomment-2566624997

   One not very clean possibility, short of adding a new method like 
`onGzipParameters()` would be to make `init()` protected instead of private. 
Then a call site could create an anonymous subclass and override `init()`. It's 
not great but possible.
   
   A little cleaner, would be to add a method called `onGzipParameters()` which 
is called from `init()` at its end, and same as above, a call site could create 
an anonymous subclass and override `onGzipParameters()`; this avoids the stream 
keeping an extra instance variable.
   
   Whether or not the above is "better" than adding an instance variable 
depends on how often this use case happens and how much we should change the 
class to accommodate for it in the design or simply allow for it do just be 
doable with a subclass.
   
   Back to bugs: It's hard to see how this is not a bug:
   ```java
           switch (inData.readUnsignedByte()) { // extra flags
           case 2:
               parameters.setCompressionLevel(Deflater.BEST_COMPRESSION);
               break;
           case 4:
               parameters.setCompressionLevel(Deflater.BEST_SPEED);
               break;
           default:
               // ignored for now
               break;
           }
   ```
   The above means that for a new member, the GP carries the previous member's 
value, right? How is that not a bug? It seems to me the code should be:
   ```java
           switch (inData.readUnsignedByte()) { // extra flags
           case 2:
               parameters.setCompressionLevel(Deflater.BEST_COMPRESSION);
               break;
           case 4:
               parameters.setCompressionLevel(Deflater.BEST_SPEED);
               break;
           default:
               parameters.setCompressionLevel(Deflater.DEFAULT_COMPRESSION);
               break;
           }
   ```
   The above change does not break the build (running `mvn` by itself) but we 
may not have the right kind of test for this use case.
   
   Checking code coverage with `mvn clean install site -P jacoco` shows that 
the new line is executed but the one for 
`parameters.setCompressionLevel(Deflater.BEST_SPEED);` isn't, so the coverage 
is not worse.
   
   WDYT?
   
   
   
   
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to