chatman commented on a change in pull request #929: SOLR-13821: Package Store 
for storing package artefacts
URL: https://github.com/apache/lucene-solr/pull/929#discussion_r331949129
 
 

 ##########
 File path: solr/solrj/src/java/org/apache/solr/common/util/Utils.java
 ##########
 @@ -713,4 +717,69 @@ public static String getMDCNode() {
     return def;
   }
 
+  public interface InputStreamConsumer<T> {
+
+    T accept(InputStream is) throws IOException;
+
+  }
+
+  public static final InputStreamConsumer<?> JAVABINCONSUMER = is -> new 
JavaBinCodec().unmarshal(is);
+  public static final InputStreamConsumer<?> JSONCONSUMER = is -> 
Utils.fromJSON(is);
+  public static InputStreamConsumer<ByteBuffer> newBytesConsumer(int maxSize){
+    return is -> {
+      try (BinaryRequestWriter.BAOS bos = new BinaryRequestWriter.BAOS()) {
+        long sz = 0;
+        int next = is.read();
+        while (next > -1) {
+          if (++sz > maxSize) throw new BufferOverflowException();
+          bos.write(next);
+          next = is.read();
+        }
+        bos.flush();
+        return ByteBuffer.wrap( bos.getbuf(), 0, bos.size());
+      } catch (IOException e) {
+        throw new RuntimeException(e);
+      }
+    };
+
+  }
+
+
+
+
+  public static <T> T executeGET(HttpClient client, String url, 
InputStreamConsumer<T> consumer) throws SolrException {
+    T result = null;
+    HttpGet httpGet = new HttpGet(url);
+    HttpResponse rsp = null;
+    try {
+      rsp = client.execute(httpGet);
+    } catch (IOException e) {
+      log.error("Error in request to url : "+ url, e);
+      throw new SolrException(SolrException.ErrorCode.UNKNOWN, "error sending 
request");
+    }
+    int statusCode = rsp.getStatusLine().getStatusCode();
+    if(statusCode != 200) {
+      try {
+        log.error("Failed a request to : {} ,  status :{}  body {}",url, 
rsp.getStatusLine(),  EntityUtils.toString(rsp.getEntity(), 
StandardCharsets.UTF_8));
 
 Review comment:
   Please remove space before colon, there should always be a space after colon.
   
   This:
   
       "Failed a request to : {} ,  status :{}  body {}"
   
   Should be:
   
       "Failed a request to: {}, status: {}, body: {}"
   
   Also, please put a space after every comma (before url).

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to