-
Notifications
You must be signed in to change notification settings - Fork 31
Ensure 304 response code does not throw exceptions #1975
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] ensure 304 response code does not throw
Ensure 304 response code does not throw exceptions
Jul 2, 2025
baywet
requested changes
Jul 2, 2025
components/http/okHttp/src/main/java/com/microsoft/kiota/http/OkHttpRequestAdapter.java
Outdated
Show resolved
Hide resolved
components/http/okHttp/src/main/java/com/microsoft/kiota/http/OkHttpRequestAdapter.java
Outdated
Show resolved
Hide resolved
Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
Contributor
Author
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
baywet
requested changes
Jul 2, 2025
components/http/okHttp/src/main/java/com/microsoft/kiota/http/OkHttpRequestAdapter.java
Outdated
Show resolved
Hide resolved
components/http/okHttp/src/main/java/com/microsoft/kiota/http/OkHttpRequestAdapter.java
Outdated
Show resolved
Hide resolved
baywet
approved these changes
Jul 2, 2025
|
adrian05-ms
approved these changes
Jul 4, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.



This PR fixes an issue where HTTP 304 (Not Modified) responses would throw
IllegalStateExceptionwhen the response body is empty or null, similar to the previous fix for 204 responses.Problem
When handling 304 responses with empty bodies, the current implementation would fail with:
Solution
Applied the same pattern already established for 204 (No Content) responses to 304 (Not Modified) responses:
shouldReturnNull()method to returntruefor 304 responses, ensuring they return null instead of attempting to parse empty contentcloseResponse()method to skip closing 304 responses, preventing theIllegalStateExceptionChanges Made
shouldReturnNull():return statusCode == 204 || statusCode == 304;closeResponse():if (closeResponse && response.code() != 204 && response.code() != 304)OkHttpRequestAdapterTestThe changes are minimal and follow the exact same pattern as the existing 204 handling, ensuring consistency and maintainability.
Fixes #1848.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
graph.microsoft.com/usr/lib/jvm/temurin-17-jdk-amd64/bin/java -Dorg.gradle.internal.worker.tmpdir=/home/REDACTED/work/kiota-java/kiota-java/components/http/okHttp/build/tmp/test/work -javaagent:/home/REDACTED/work/kiota-java/kiota-java/components/http/okHttp/build/tmp/.cache/expanded/zip_ff7bf8f04f99dc306508d1c81e47a68b/jacocoagent.jar=destfile=build/jacoco/test.exec,append=true,inclnolocationclasses=false,dumponexit=true,output=file,jmx=false @/home/REDACTED/.gradle/.tmp/gradle-worker-classpath18252088451007800667txt -Xmx512m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -ea worker.org.gradle.process.internal.worker.GradleWorkerMain 'Gradle Test Executor 4'(dns block)/usr/lib/jvm/temurin-17-jdk-amd64/bin/java -Dorg.gradle.internal.worker.tmpdir=/home/REDACTED/work/kiota-java/kiota-java/components/http/okHttp/build/tmp/test/work -javaagent:/home/REDACTED/work/kiota-java/kiota-java/components/http/okHttp/build/tmp/.cache/expanded/zip_ff7bf8f04f99dc306508d1c81e47a68b/jacocoagent.jar=destfile=build/jacoco/test.exec,append=true,inclnolocationclasses=false,dumponexit=true,output=file,jmx=false @/home/REDACTED/.gradle/.tmp/gradle-worker-classpath7775169814115159399txt -Xmx512m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -ea worker.org.gradle.process.internal.worker.GradleWorkerMain 'Gradle Test Executor 1'(dns block)www.google.com/usr/lib/jvm/temurin-17-jdk-amd64/bin/java -Dorg.gradle.internal.worker.tmpdir=/home/REDACTED/work/kiota-java/kiota-java/components/http/okHttp/build/tmp/test/work -javaagent:/home/REDACTED/work/kiota-java/kiota-java/components/http/okHttp/build/tmp/.cache/expanded/zip_ff7bf8f04f99dc306508d1c81e47a68b/jacocoagent.jar=destfile=build/jacoco/test.exec,append=true,inclnolocationclasses=false,dumponexit=true,output=file,jmx=false @/home/REDACTED/.gradle/.tmp/gradle-worker-classpath18252088451007800667txt -Xmx512m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -ea worker.org.gradle.process.internal.worker.GradleWorkerMain 'Gradle Test Executor 4'(dns block)/usr/lib/jvm/temurin-17-jdk-amd64/bin/java -Dorg.gradle.internal.worker.tmpdir=/home/REDACTED/work/kiota-java/kiota-java/components/http/okHttp/build/tmp/test/work -javaagent:/home/REDACTED/work/kiota-java/kiota-java/components/http/okHttp/build/tmp/.cache/expanded/zip_ff7bf8f04f99dc306508d1c81e47a68b/jacocoagent.jar=destfile=build/jacoco/test.exec,append=true,inclnolocationclasses=false,dumponexit=true,output=file,jmx=false @/home/REDACTED/.gradle/.tmp/gradle-worker-classpath7775169814115159399txt -Xmx512m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -ea worker.org.gradle.process.internal.worker.GradleWorkerMain 'Gradle Test Executor 1'(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.