-
Notifications
You must be signed in to change notification settings - Fork 280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG-3581] [Code Style] HttpStatus & Headers should not be imported from org.apache.hc.core5.http
#3663
[BUG-3581] [Code Style] HttpStatus & Headers should not be imported from org.apache.hc.core5.http
#3663
Conversation
Signed-off-by: Prabhas Kurapati <[email protected]>
Signed-off-by: Prabhas Kurapati <[email protected]>
Signed-off-by: Prabhas Kurapati <[email protected]>
Signed-off-by: Prabhas Kurapati <[email protected]>
Signed-off-by: Prabhas Kurapati <[email protected]>
Signed-off-by: Prabhas Kurapati <[email protected]>
org.apache.hc.core5.http
Signed-off-by: Prabhas Kurapati <[email protected]>
@cwperks @scrawfor99 @DarshitChanpura @peternied Through updating the illegal import To solve this problem I can either manually add a cast to |
@prabhask5 why |
I'm referencing #3581 , if its not illegal I might be misunderstanding what the issue is saying. |
Me neither, the |
@prabhask5 thanks for being proactive on this. Similar to @reta: I am not sure what the original issue was referencing. I don't think that it will be possible to standardize the versions without significant refactoring. You will need to swap to the v4 equivalents for everything in main. Eventually we will move to 3.0 and likely swap completely to v5 when we do. I don't think it makes sense to spend too much time converting the versions back and forth. |
So is this issue irrelevant then? @peternied Do you have some insight on this? |
Illegal has weighty connotations - I'd prefer to think of direct imports of @reta What do you think about this rational? After we release 3.0.0, we will still be supporting 2.x builds for a least a year, anything that helps make the backport process result in less merge conflicts is a solid win to me. |
@prabhask5 Looks like there are many merge conflicts that you'll need to resolve - I'd suggest a |
@peternied Sounds good. How do you recommend fixing the errors I'm getting? I have them copied below for convenience. Through updating the illegal import org.apache.hc.core5.http.Header, to org.apache.http.Header I'm getting a lot of type compilation errors that try unsuccessfully to cast org.apache.hc.core5.http.Header to org.apache.http.Header. Here is an example of one such error: /Users/prabhask/Documents/Internships/opensearch-security/src/test/java/org/opensearch/security/test/helper/rest/RestHelper.java:238: error: incompatible types: org.apache.http.Header cannot be converted to org.apache.hc.core5.http.Header To solve this problem I can either manually add a cast to org.apache.hc.core5.http.Header whenever this error appears or change the imports of all the dependent classes to also exclude core5 or client5, both of which seem like bad solutions. Is there another way to solve this problem? |
|
@peternied I'm pretty confused on these solutions. The majority of the errors I'm getting are either functions where the new Header is not an applicable type for the parameter, but I can't edit these functions since they are in the Apache codebase. How should I fix these errors? The only solution I'm seeing is to manually cast to the new type of Header, which again I don't think is advisable. A more specific solution would help a lot, ty! |
@prabhask5 I might recommend going with the first option, remove changes for This change is already massive and providing feedback is non-trivial if you are running into build/runtime issues. |
Signed-off-by: Prabhas Kurapati <[email protected]>
Signed-off-by: Prabhas Kurapati <[email protected]>
Signed-off-by: Prabhas Kurapati <[email protected]>
@peternied Done! Feel free to unblock tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see mixed usages of 4 & 5. Also some classes still import Header from 5 vs 4, is that expected?
@reta thoughts?
@@ -16,6 +16,8 @@ | |||
import java.util.Map; | |||
|
|||
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; | |||
import io.jsonwebtoken.SignatureAlgorithm; | |||
import io.jsonwebtoken.security.Keys; | |||
import org.apache.hc.core5.http.Header; | |||
import org.apache.hc.core5.http.message.BasicHeader; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems to be unrelated. The original import for hc5 still remains as is
import io.jsonwebtoken.Claims; | ||
import io.jsonwebtoken.Jwts; | ||
import io.jsonwebtoken.security.Keys; | ||
|
||
import org.apache.hc.core5.http.Header; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why only 1 of these 2 changed?
@@ -20,7 +20,7 @@ | |||
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; | |||
import org.apache.hc.client5.http.classic.methods.HttpPost; | |||
import org.apache.hc.core5.http.ContentType; | |||
import org.apache.hc.core5.http.HttpStatus; | |||
import org.apache.http.HttpStatus; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be a mixed usage between 4 & 5?
@@ -22,7 +22,8 @@ | |||
import java.util.stream.Collectors; | |||
|
|||
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; | |||
import org.apache.hc.core5.http.HttpStatus; | |||
import joptsimple.internal.Strings; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this import? is it being used?
@@ -15,6 +15,7 @@ | |||
import java.util.List; | |||
|
|||
import org.apache.hc.core5.http.Header; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: seems like this import was not replaced
@@ -11,10 +11,8 @@ | |||
|
|||
package org.opensearch.security.system_indices; | |||
|
|||
import java.io.IOException; | |||
|
|||
import org.apache.hc.core5.http.Header; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be org.apache.http.HttpStatus
Signed-off-by: Prabhas Kurapati <[email protected]>
Closed PR due to git issues new PR here: #3741 |
Description
Accounts for refactor of Header and HttpStatus classes from hc.cor5.http to just http by adding checkstyle test, and manually refactoring all current occurrences of the illegal import. Additionally updated spotlessApply to make the refactor automatic on future cases of illegal import.
Bug fix/refactor
Refer to #3581
Ideally nothing.
Issues Resolved
org.apache.hc.core5.http
#3581Is this a backport? If so, please add backport PR # and/or commits #
No.
Testing
Tests have been modified and should work before merging.
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.