[jira] [Commented] (SCB-992) Synchronous open source code from Vert.x 3.5.3 version
[ https://issues.apache.org/jira/browse/SCB-992?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16669467#comment-16669467 ] ASF GitHub Bot commented on SCB-992: liubao68 closed pull request #973: [SCB-992] Synchronous open source code from Vert.x 3.5.3 version URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/973 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/transports/transport-rest/transport-rest-vertx/src/main/java/org/apache/servicecomb/transport/rest/vertx/RestBodyHandler.java b/transports/transport-rest/transport-rest-vertx/src/main/java/org/apache/servicecomb/transport/rest/vertx/RestBodyHandler.java index a02dffc30..7e8105fad 100644 --- a/transports/transport-rest/transport-rest-vertx/src/main/java/org/apache/servicecomb/transport/rest/vertx/RestBodyHandler.java +++ b/transports/transport-rest/transport-rest-vertx/src/main/java/org/apache/servicecomb/transport/rest/vertx/RestBodyHandler.java @@ -24,6 +24,7 @@ import java.io.File; import java.util.Set; import java.util.UUID; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import javax.ws.rs.core.Response.Status; @@ -33,7 +34,6 @@ import org.apache.servicecomb.swagger.invocation.exception.InvocationException; import io.netty.handler.codec.http.HttpHeaderValues; -import io.netty.handler.codec.http.multipart.HttpPostRequestDecoder.ErrorDataDecoderException; import io.vertx.core.Handler; import io.vertx.core.buffer.Buffer; import io.vertx.core.file.FileSystem; @@ -78,6 +78,11 @@ public RestBodyHandler(String uploadDirectory) { @Override public void handle(RoutingContext context) { HttpServerRequest request = context.request(); +if (request.headers().contains(HttpHeaders.UPGRADE, HttpHeaders.WEBSOCKET, true)) { + context.next(); + return; +} + // we need to keep state since we can be called again on reroute Boolean handled = context.get(BODY_HANDLED); if (handled == null || !handled) { @@ -129,6 +134,8 @@ public BodyHandler setDeleteUploadedFilesOnEnd(boolean deleteUploadedFilesOnEnd) private AtomicInteger uploadCount = new AtomicInteger(); +AtomicBoolean cleanup = new AtomicBoolean(false); + private boolean ended; private long uploadSize = 0L; @@ -159,21 +166,37 @@ public BodyHandler setDeleteUploadedFilesOnEnd(boolean deleteUploadedFilesOnEnd) if (uploadsDir == null) { failed = true; CommonExceptionData data = new CommonExceptionData("not support file upload."); -throw new ErrorDataDecoderException(ExceptionFactory.createConsumerException(data)); +context.fail(ExceptionFactory.createProducerException(data)); +return; } // *** cse end *** - + if (bodyLimit != -1 && upload.isSizeAvailable()) { +// we can try to abort even before the upload starts +long size = uploadSize + upload.size(); +if (size > bodyLimit) { + failed = true; + context.fail(new InvocationException(Status.REQUEST_ENTITY_TOO_LARGE, + Status.REQUEST_ENTITY_TOO_LARGE.getReasonPhrase())); + return; +} + } // we actually upload to a file with a generated filename uploadCount.incrementAndGet(); String uploadedFileName = new File(uploadsDir, UUID.randomUUID().toString()).getPath(); upload.streamToFileSystem(uploadedFileName); FileUploadImpl fileUpload = new FileUploadImpl(uploadedFileName, upload); fileUploads.add(fileUpload); - upload.exceptionHandler(context::fail); + upload.exceptionHandler(t -> { +deleteFileUploads(); +context.fail(t); + }); upload.endHandler(v -> uploadEnded()); }); } - context.request().exceptionHandler(context::fail); + context.request().exceptionHandler(t -> { +deleteFileUploads(); +context.fail(t); + }); } private void makeUploadDir(FileSystem fileSystem) { @@ -196,8 +219,10 @@ public void handle(Buffer buff) { uploadSize += buff.length(); if (bodyLimit != -1 && uploadSize > bodyLimit) { failed = true; +// enqueue a delete for the error uploads context.fail(new InvocationException(Status.REQUEST_ENTITY_TOO_LARGE, Status.REQUEST_ENTITY_TOO_LARGE.getReasonPhrase())); +context.vertx().runOnContext(v -> deleteFileUploads()); } else { // multipart requests will not end up in the request body // url encoded should
[jira] [Commented] (SCB-992) Synchronous open source code from Vert.x 3.5.3 version
[ https://issues.apache.org/jira/browse/SCB-992?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16668596#comment-16668596 ] ASF GitHub Bot commented on SCB-992: jeho0815 edited a comment on issue #973: [SCB-992] Synchronous open source code from Vert.x 3.5.3 version URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/973#issuecomment-434184375 > Can you discribe what's the problem of this improment? Can't get it from the title Vertx 3.5.3 BodyHandlerImpl has some changes and bug fixes, such as [ #789](https://github.com/vert-x3/vertx-web/pull/789), the most code of RestBodyHandler in ServiceComb is similar with it, so we should synchronous those changes into servicecomb This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Synchronous open source code from Vert.x 3.5.3 version > -- > > Key: SCB-992 > URL: https://issues.apache.org/jira/browse/SCB-992 > Project: Apache ServiceComb > Issue Type: Task > Components: Java-Chassis >Reporter: jeho0815 >Assignee: jeho0815 >Priority: Major > Fix For: java-chassis-1.1.0 > > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-992) Synchronous open source code from Vert.x 3.5.3 version
[ https://issues.apache.org/jira/browse/SCB-992?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16668209#comment-16668209 ] ASF GitHub Bot commented on SCB-992: jeho0815 commented on issue #973: [SCB-992] Synchronous open source code from Vert.x 3.5.3 version URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/973#issuecomment-434184375 > Can you discribe what's the problem of this improment? Can't get it from the title Vertx 3.5.3 BodyHandlerImpl has some changes and bug fixes, such as , the most code of RestBodyHandler in ServiceComb is similar with it, so we should synchronous those changes into servicecomb This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Synchronous open source code from Vert.x 3.5.3 version > -- > > Key: SCB-992 > URL: https://issues.apache.org/jira/browse/SCB-992 > Project: Apache ServiceComb > Issue Type: Task > Components: Java-Chassis >Reporter: jeho0815 >Assignee: jeho0815 >Priority: Major > Fix For: java-chassis-1.1.0 > > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-992) Synchronous open source code from Vert.x 3.5.3 version
[ https://issues.apache.org/jira/browse/SCB-992?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16668102#comment-16668102 ] ASF GitHub Bot commented on SCB-992: coveralls commented on issue #973: [SCB-992] Synchronous open source code from Vert.x 3.5.3 version URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/973#issuecomment-434165878 [![Coverage Status](https://coveralls.io/builds/19796161/badge)](https://coveralls.io/builds/19796161) Coverage decreased (-0.05%) to 86.334% when pulling **a1439fe42fd421f22295d11d1667a60c9f021f80 on jeho0815:Branch_master_SCB-992** into **0daff2ebb2444c1ef6b0deaca545c0821207f0cc on apache:master**. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Synchronous open source code from Vert.x 3.5.3 version > -- > > Key: SCB-992 > URL: https://issues.apache.org/jira/browse/SCB-992 > Project: Apache ServiceComb > Issue Type: Task > Components: Java-Chassis >Reporter: jeho0815 >Assignee: jeho0815 >Priority: Major > Fix For: java-chassis-1.1.0 > > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-992) Synchronous open source code from Vert.x 3.5.3 version
[ https://issues.apache.org/jira/browse/SCB-992?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16667017#comment-16667017 ] ASF GitHub Bot commented on SCB-992: jeho0815 opened a new pull request #973: [SCB-992] Synchronous open source code from Vert.x 3.5.3 version URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/973 Follow this checklist to help us incorporate your contribution quickly and easily: - [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/SCB) filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes. - [ ] Each commit in the pull request should have a meaningful subject line and body. - [ ] Format the pull request title like `[SCB-XXX] Fixes bug in ApproximateQuantiles`, where you replace `SCB-XXX` with the appropriate JIRA issue. - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [ ] Run `mvn clean install` to make sure basic checks pass. A more thorough check will be performed on your pull request automatically. - [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf). --- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Synchronous open source code from Vert.x 3.5.3 version > -- > > Key: SCB-992 > URL: https://issues.apache.org/jira/browse/SCB-992 > Project: Apache ServiceComb > Issue Type: Task > Components: Java-Chassis >Reporter: jeho0815 >Assignee: jeho0815 >Priority: Major > Fix For: java-chassis-1.1.0 > > -- This message was sent by Atlassian JIRA (v7.6.3#76005)