[improve][proxy] Add regression tests for package upload with 'Expect: 100-continue'#25211
[improve][proxy] Add regression tests for package upload with 'Expect: 100-continue'#25211nodece merged 9 commits intoapache:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes proxy package uploads when clients send Expect: 100-continue by ensuring the proxy does not forward the Expect header to brokers, preventing Early EOF errors during large uploads.
Changes:
- Add request wrapping in
AdminProxyHandlerto strip theExpectheader whenExpect: 100-continueis present. - Add proxy package upload/download tests, including an
Expect: 100-continuescenario with a large multipart upload. - Improve mocked packages storage test implementation to read streams in chunks and add unit tests for large read/write correctness.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/AdminProxyHandler.java | Wraps requests that use Expect: 100-continue to prevent forwarding the Expect header to brokers. |
| pulsar-proxy/src/test/java/org/apache/pulsar/proxy/server/ProxyPackagesUploadTest.java | Adds integration coverage for uploading/downloading packages through the proxy, including Expect: 100-continue. |
| pulsar-proxy/pom.xml | Adds pulsar-package-core test-jar dependency for proxy tests using mock package storage. |
| pulsar-package-management/core/src/test/java/org/apache/pulsar/packages/management/core/MockedPackagesStorage.java | Refactors mocked storage writes to read streams in buffered chunks (supports large uploads). |
| pulsar-package-management/core/src/test/java/org/apache/pulsar/packages/management/core/MockedPackagesStorageTest.java | Adds a unit test validating mocked storage write/read correctness for large payloads. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
lhotari
left a comment
There was a problem hiding this comment.
- Added logic in
AdminProxyHandlerto detect requests with the
"Expect: 100-continue" header and wrap them using
NoExpectRequestWrapper, ensuring the header is not forwarded to the
broker and preventing Early EOF.- Introduced the
NoExpectRequestWrapperinner class to filter out the
"Expect" header from incoming requests.
I'm not sure if this is the correct approach. Expect: 100-continue is related to Transfer-Encoding: Chunked. Usually Transfer-Encoding: Chunked is used when Content-Length header isn't set due to the size of the body being unknown when the request is started.
While upgrading Jetty from 9.x to 12.x, I noticed that ProxyContinueProtocolHandler was missing from AdminProxyHandler:
A similar change should be implemented in branch-4.1, branch-4.0 and branch-3.0 to fix the Transfer-Encoding: Chunked and Expect: 100-continue support.
In addition, if httpMaxRequestSize is set in configuration, that would block Transfer-Encoding: Chunked:
I checked this claim that I made. It's not correct. |
The reason why this doesn't make sense is that the client won't be sending a body when the request contains |
|
Both the jetty 9.x and 12.x have this issue. |
|
Now, the client sent "Expect: 100-continue". Based on curl verbose output, it seems Jetty responds with "100 Continue" automatically. |
|
I will try to use the ProxyContinueProtocolHandler tomorrow. |
One possible approach would be to change the |
…and maintainability
|
Thanks for the suggestion, and I agree that this is a better and cleaner approach. After validating the behavior with packet captures, I realized that my previous change only guarantees correct handling of Your proposal to have |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 8 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…/packages/management/core/MockedPackagesStorage.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…nProxyHandler.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…/packages/management/core/MockedPackagesStorageTest.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…: 100-continue' (apache#25211) Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> (cherry picked from commit e8fedb1)
…: 100-continue' (apache#25211) Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> (cherry picked from commit e8fedb1)
…: 100-continue' (apache#25211) Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> (cherry picked from commit e8fedb1)
…: 100-continue' (apache#25211) Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> (cherry picked from commit e8fedb1) (cherry picked from commit 0947639)
…: 100-continue' (apache#25211) Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> (cherry picked from commit e8fedb1) (cherry picked from commit 1d25d04)
…: 100-continue' (apache#25211) Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> (cherry picked from commit e8fedb1) (cherry picked from commit 0947639)
…: 100-continue' (apache#25211) Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> (cherry picked from commit e8fedb1) (cherry picked from commit 1d25d04)
…datastax 4 0 ds 16 feb (#589) * [improve][broker] Ensure metadata session state visibility and improve Unstable observability for ServiceUnitStateChannelImpl (apache#25132) (cherry picked from commit 2a29be0) (cherry picked from commit 85dc758) * [improve][broker] Upgrade bookkeeper to 4.17.3 (apache#25166) (cherry picked from commit 45def39) (cherry picked from commit 333110a) * fix license and pom file * [fix][ml] Fix NoSuchElementException in EntryCountEstimator caused by a race condition (apache#25177) (cherry picked from commit 9b70ba3) (cherry picked from commit 9261869) * [fix][test] Bump org.assertj:assertj-core from 3.27.5 to 3.27.7 (apache#25186) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> (cherry picked from commit ce4ebea) (cherry picked from commit 2c3402e) * [improve][misc] Upgrade snappy version to 1.1.10.8 (apache#25182) (cherry picked from commit b15f53b) (cherry picked from commit 304fea1) * [fix][proxy] Close client connection immediately when credentials expire and forwardAuthorizationCredentials is disabled (apache#25179) (cherry picked from commit 3348470) (cherry picked from commit c06f8ba) * [fix][client] ControlledClusterFailover avoid unnecessary reconnection. (apache#25178) Co-authored-by: fengwenzhi <fengwenzhi.max@bigo.sg> (cherry picked from commit f0ec07b) (cherry picked from commit b41488d) * [fix][sec] Bump org.apache.solr:solr-core from 9.8.0 to 9.10.1 in /pulsar-io/solr (apache#25175) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> (cherry picked from commit a2f888a) (cherry picked from commit b532068) * [improve][pip] PIP-453: Improve the metadata store threading model (apache#25173) (cherry picked from commit c51346f) (cherry picked from commit d81d6b3) * [improve][client]Reduce unnecessary getPartitionedTopicMetadata requests when using retry and DLQ topics. (apache#25172) (cherry picked from commit 52a4d5e) (cherry picked from commit 71a3994) * [fix][misc] Allow JWT tokens in OpenID auth without nbf claim (apache#25197) (cherry picked from commit d630394) (cherry picked from commit 2760ee9) * [fix][sec] Exclude org.lz4:lz4-java and standardize on at.yawk.lz4-java to remediate CVE-2025-12183 and CVE-2025-66566 (apache#25198) (cherry picked from commit c07f2ad) (cherry picked from commit 2ac6d03) * fix checkstyle failure and license issues * [fix] [test] Upgrade docker-java to 3.7.0 (apache#25209) (cherry picked from commit 4add84c) (cherry picked from commit 92b5d55) * [fix][client] Fix race condition between isDuplicate() and flushAsync() method in PersistentAcknowledgmentsGroupingTracker due to incorrect use Netty Recycler (apache#25208) (cherry picked from commit 5aab2f0) (cherry picked from commit 2206949) * [improve][monitor] Upgrade OpenTelemetry to 1.56.0, Otel instrumentation to 2.21.0 and Otel semconv to 1.37.0 (apache#24994) (cherry picked from commit 53162ff) (cherry picked from commit a1d5b6c) * [improve][proxy] Add regression tests for package upload with 'Expect: 100-continue' (apache#25211) Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> (cherry picked from commit e8fedb1) (cherry picked from commit 0947639) * fix license issues * [fix][test]Fix flaky ExtensibleLoadManagerImplTest_testGetMetrics (apache#25216) (cherry picked from commit 257d42f) (cherry picked from commit a8eac91) * [fix][broker] Fix ManagedCursorImpl.asyncDelete() method may lose previous async mark delete properties in race condition (apache#25165) (cherry picked from commit bea6f8a) (cherry picked from commit 4332a44) * [fix][broker]Fix ledgerHandle failed to read by using new BK API (apache#25199) (cherry picked from commit 6d51f88) (cherry picked from commit 1631fed) * [fix][client] Fix producer synchronous retry handling in failPendingMessages method (apache#25207) (cherry picked from commit 611efe4) (cherry picked from commit 30ae8fb) * [fix][broker] Prevent missed topic changes in topic watchers and schedule periodic refresh with patternAutoDiscoveryPeriod interval (apache#25188) (cherry picked from commit 2e06cc0) (cherry picked from commit ba2a230) * fix for complilation error * [feat][io] implement pip-297 for jdbc sinks (apache#25195) (cherry picked from commit 6f4ac21) (cherry picked from commit 998a4b1) * [fix][broker] Fix httpProxyTimeout config (apache#25223) Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> (cherry picked from commit 2d6ef6f) (cherry picked from commit 3b39c7b) * [improve][broker] Add strictAuthMethod to require explicit authentication method (apache#25185) Co-authored-by: Ómar K. Yasin <oyasin@apple.com> (cherry picked from commit bae9173) (cherry picked from commit 27e34f6) * [feat][client] oauth2 trustcerts file and timeouts (apache#24944) (cherry picked from commit b789d82) (cherry picked from commit f8827bd) * [improve][client] Make authorization server metadata path configurable in AuthenticationOAuth2 (apache#25052) Co-authored-by: hoguni <hoguni@lycorp.co.jp> (cherry picked from commit 3cb7a7b) (cherry picked from commit 705a99d) * Revert "[improve][broker] Add strictAuthMethod to require explicit authentication method (apache#25185)" This reverts commit 531eb91. * [improve][broker] Add idle timeout support for http (apache#25224) (cherry picked from commit 63220ea) (cherry picked from commit 144e064) * [fix][broker] Fix incomplete futures in topic property update/delete methods (apache#25228) (cherry picked from commit c2ae180) (cherry picked from commit ab05ca2) * [fix][test] Fix Mockito stubbing race in TopicListServiceTest (apache#25227) (cherry picked from commit c93dd7a) (cherry picked from commit 38a126b) * [improve][broker] Give the detail error msg when authenticate failed with AuthenticationException (apache#25221) (cherry picked from commit 0a0ce6d) (cherry picked from commit 2a46c70) * [fix][client] Send all chunkMessageIds to broker for redelivery (apache#25229) (cherry picked from commit 0a0ce6d) (cherry picked from commit f49c7b2) * [fix][broker] Fix transactionMetadataFuture completeExceptionally with null value (apache#25231) Co-authored-by: 张浩 <zhanghao60@100.me> (cherry picked from commit 0e5d424) (cherry picked from commit 42283f4) * uncomment distribution management in pom * Reapply "[improve][meta] PIP-453: Improve the metadata store threading model (apache#25187)" This reverts commit a6aab86. (cherry picked from commit 4f9b2ca) * [improve] Upgrade Netty to 4.1.131.Final (apache#25232) (cherry picked from commit db91b93) (cherry picked from commit a6c602a) * [fix][test] fix testBatchMetadataStoreMetrics. (apache#25241) (cherry picked from commit 9db31cc) (cherry picked from commit abbd478) * [fix][test] Fix ResourceQuotaCalculatorImplTest#testNeedToReportLocalUsage (apache#25247) (cherry picked from commit 48774de) (cherry picked from commit 9343837) * [fix][meta] Metadata cache refresh might not take effect (apache#25246) (cherry picked from commit 24eba10) (cherry picked from commit 6d81292) * fix pulsar-proxy unit test case failure * fix safe delete URLRegexLookupProxyHandler which is not used * Revert "fix safe delete URLRegexLookupProxyHandler which is not used" This reverts commit 158fc14. * Revert "fix pulsar-proxy unit test case failure" This reverts commit 4efcf70. * updated hardcoded newLookupProxyHandler in ProxyService for failing URLRegexLookupProxyHandlerTest * Revert "[improve][monitor] Upgrade OpenTelemetry to 1.56.0, Otel instrumentation to 2.21.0 and Otel semconv to 1.37.0 (apache#24994)" This reverts commit 5e5328e * reverted lincense for opentelemetry upgrade changes * Revert "updated hardcoded newLookupProxyHandler in ProxyService for failing URLRegexLookupProxyHandlerTest" This reverts commit a4f07dc. * reverted mismatch commits changes in ProxyConnection.java * fix code-style issue --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Kai Wang <kwang@apache.org> Co-authored-by: Yong Zhang <zhangyong1025.zy@gmail.com> Co-authored-by: Lari Hotari <lhotari@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Zixuan Liu <nodeces@gmail.com> Co-authored-by: Wenzhi Feng <thetumbled@apache.org> Co-authored-by: fengwenzhi <fengwenzhi.max@bigo.sg> Co-authored-by: Yunze Xu <xyzinfernity@163.com> Co-authored-by: zhenJiangWang <zhenjiang427@gmail.com> Co-authored-by: guptas6est <sanaya.gupta@est.tech> Co-authored-by: Matteo Merli <mmerli@apache.org> Co-authored-by: Oneby Wang <44369297+oneby-wang@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: fengyubiao <yubiao.feng@streamnative.io> Co-authored-by: Malla Sandeep <sandeep.malla78@gmail.com> Co-authored-by: Bäm <dev@sandchaschte.ch> Co-authored-by: Omar Yasin <omarkj@icloud.com> Co-authored-by: Ómar K. Yasin <oyasin@apple.com> Co-authored-by: gulecroc <gu.lecroc@gmail.com> Co-authored-by: Hideaki Oguni <22386882+izumo27@users.noreply.github.com> Co-authored-by: hoguni <hoguni@lycorp.co.jp> Co-authored-by: Cong Zhao <zhaocong@apache.org> Co-authored-by: sinan liu <liusinan1998@gmail.com> Co-authored-by: Jiwei Guo <technoboy@apache.org> Co-authored-by: cai minjian <905767378@qq.com> Co-authored-by: Hao Zhang <zhanghao1@cmss.chinamobile.com> Co-authored-by: 张浩 <zhanghao60@100.me> Co-authored-by: Lari Hotari <lhotari@apache.org> Co-authored-by: zzb <48124861+zhaizhibo@users.noreply.github.com>
…: 100-continue' (apache#25211) Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> (cherry picked from commit e8fedb1) (cherry picked from commit 0947639)
Motivation
This pull request introduces improvements and new tests for package management and proxy upload functionality in Pulsar.
Although PulsarAdmin (based on
async-http-client) does not send the'Expect: 100-continue'header by default, we observed in production that some HTTP clients (for examplecurlor other generic upload tools) do send thisheader when uploading large packages through the Pulsar proxy.
In older Pulsar versions, such requests may lead to Early EOF issues during package uploads through the proxy. Adding coverage for this scenario helps ensure that large uploads using
'Expect: 100-continue'work reliably andremain compatible with common HTTP clients.
Modifications
Package management improvements
MockedPackagesStorage.writeAsyncto read input streams using a buffer andByteArrayOutputStream, improving correctness for large files and for streams whereInputStream.available()is unreliable.MockedPackagesStorageTestto validate correct write and read behavior for large package data in the mocked storage implementation.Proxy upload tests
ProxyPackagesUploadTestto verify package upload and download through the Pulsar proxy and broker.'Expect: 100-continue'header to prevent regressions related to Early EOF issues observed in production.Codebase simplification
AdminProxyHandlerby reusing the HTTP client configuration from the superclass and customizing only the required protocol handlers, reducing code duplication and improving maintainability.Documentation
docdoc-requireddoc-not-neededdoc-complete