-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Fix the content type retrieval #7013
Conversation
@benmoriceau let me know when you feel this contribution can be reviewed. |
Hello @marcosmarxm, Thanks for the quick feedback. This review is a draft since I am learning the build system. I will check with @jrhizor if I properly respect the good practices when he reach the office. |
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.
Looks good!
The JSON library is the only real issue.
@@ -116,4 +142,17 @@ private static String redactSensitiveInfo(String requestBody) { | |||
return requestBody; | |||
} | |||
|
|||
private static boolean isValidJson(String json) { |
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.
We're using Jackson for JSON manipulation almost everywhere and we have a few helpers for it. Can we use Jsons.tryDeserialize
instead?
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.
Done
airbyte-server/build.gradle
Outdated
@@ -57,6 +57,7 @@ dependencies { | |||
implementation 'org.glassfish.jersey.media:jersey-media-json-jackson' | |||
implementation 'org.glassfish.jersey.ext:jersey-bean-validation' | |||
implementation "org.flywaydb:flyway-core:7.14.0" | |||
implementation 'org.json:json:20210307' |
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.
See other comment, we can remove this dependency if we use already imported JSON libs.
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.
Done
final List<String> splitLogs = Lists.newArrayList(logs.split(System.lineSeparator())); | ||
Assertions.assertThat(splitLogs) | ||
.extracting((line) -> line.endsWith(expectedLog) && line.contains(expectedLogLevel)) | ||
.containsOnlyOnce(true); |
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.
final List<String> splitLogs = Lists.newArrayList(logs.split(System.lineSeparator())); | |
Assertions.assertThat(splitLogs) | |
.extracting((line) -> line.endsWith(expectedLog) && line.contains(expectedLogLevel)) | |
.containsOnlyOnce(true); | |
final Stream<String> matchingLines = logs.lines() | |
.filter(line -> line.endsWith(expectedLog)) | |
.filter(line -> line.contains(expectedLogLevel)); | |
assertEquals(1, matchingLines.count()); |
Nitpick: personally easier to read with a count of matches instead of a stream of booleans and checking for true
. I'm not against adding assertj in general though.
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 switch it to the filter version but I kept assetJ for the comparison.
private static final String method = "POST"; | ||
private static final String remoteAddr = "123.456.789.101"; | ||
private static final String url = "/api/v1/test"; |
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.
private static final String method = "POST"; | |
private static final String remoteAddr = "123.456.789.101"; | |
private static final String url = "/api/v1/test"; | |
private static final String METHOD = "POST"; | |
private static final String REMOTE_ADDR = "123.456.789.101"; | |
private static final String URL = "/api/v1/test"; |
and usages ofc
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.
done
* Fix the content type retrieval * Re-add the original MIME type * Fix CS * Update logic and add a test * Auto format * PR comments
What
This is addressing #5900, the content-type retrieval was not working properly and some binary rows were getting log.
How
Use the MIME type describe in https://www.iana.org/assignments/media-types/media-types.xhtml