asterixdb-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Till Westmann (Code Review)" <do-not-re...@asterixdb.incubator.apache.org>
Subject Change in asterixdb[master]: [ASTERIXDB-2165] Avoid OOM in QueryServiceServlet
Date Tue, 14 Nov 2017 16:47:30 GMT
Till Westmann has uploaded a new change for review.

  https://asterix-gerrit.ics.uci.edu/2150

Change subject: [ASTERIXDB-2165] Avoid OOM in QueryServiceServlet
......................................................................

[ASTERIXDB-2165] Avoid OOM in QueryServiceServlet

- user model changes: no
- storage format changes: no
- interface change: no

Change-Id: I74f61941f2e75e10f2accd6b2e6be6c1c0cd1490
---
M asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryServiceServlet.java
1 file changed, 4 insertions(+), 9 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/50/2150/1

diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryServiceServlet.java
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryServiceServlet.java
index f8f5c18..2c22926 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryServiceServlet.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryServiceServlet.java
@@ -381,8 +381,7 @@
         RequestParameters param = getRequestParameters(request);
         LOGGER.info(param.toString());
         long elapsedStart = System.nanoTime();
-        final StringWriter stringWriter = new StringWriter();
-        final PrintWriter resultWriter = new PrintWriter(stringWriter);
+        final PrintWriter resultWriter = response.writer();
 
         ResultDelivery delivery = parseResultDelivery(param.mode);
 
@@ -392,6 +391,7 @@
         HttpUtil.setContentType(response, HttpUtil.ContentType.APPLICATION_JSON, HttpUtil.Encoding.UTF8);
 
         HttpResponseStatus status = HttpResponseStatus.OK;
+        response.setStatus(status);
         Stats stats = new Stats();
         long[] execStartEnd = new long[] { -1, -1 };
 
@@ -416,6 +416,7 @@
             }
             errorCount = 0;
         } catch (Exception | TokenMgrError | org.apache.asterix.aqlplus.parser.TokenMgrError
e) {
+            // TODO(tillw) ouch
             status = handleExecuteStatementException(e);
             ResultUtil.printError(resultWriter, e);
             ResultUtil.printStatus(sessionOutput, ResultStatus.FATAL);
@@ -430,13 +431,7 @@
                 stats.getCount(), stats.getSize(), stats.getProcessedObjects(), errorCount);
         resultWriter.print("}\n");
         resultWriter.flush();
-        String result = stringWriter.toString();
-
-        GlobalConfig.ASTERIX_LOGGER.log(Level.FINE, result);
-
-        response.setStatus(status);
-        response.writer().print(result);
-        if (response.writer().checkError()) {
+        if (resultWriter.checkError()) {
             LOGGER.warning("Error flushing output writer");
         }
     }

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/2150
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I74f61941f2e75e10f2accd6b2e6be6c1c0cd1490
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Till Westmann <tillw@apache.org>

Mime
View raw message