sonatype-lift[bot] commented on code in PR #975:
URL: https://github.com/apache/solr/pull/975#discussion_r966312263
##########
solr/solrj/src/java/org/apache/solr/client/solrj/ResponseParser.java:
##########
@@ -34,11 +37,22 @@ public abstract class ResponseParser {
* A well behaved ResponseParser will return its content-type.
*
* @return the content-type this parser expects to parse
+ * @deprecated use {@link #getContentTypes()} instead
*/
+ @Deprecated
public String getContentType() {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):*
This deprecated API looks inlineable. If you'd like the body of the API to be
inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "null")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with
***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this
PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified
`file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see
its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new)
to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not
relevant](https://www.sonatype.com/lift-comment-rating?comment=329346514&lift_comment_rating=1)
] - [ [đ Won't
fix](https://www.sonatype.com/lift-comment-rating?comment=329346514&lift_comment_rating=2)
] - [ [đ Not critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=329346514&lift_comment_rating=3)
] - [ [đ Critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=329346514&lift_comment_rating=4)
] - [ [đ Critical, fixing
now](https://www.sonatype.com/lift-comment-rating?comment=329346514&lift_comment_rating=5)
]
##########
solr/core/src/java/org/apache/solr/jersey/container/ContainerRequestUtils.java:
##########
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.jersey.container;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.security.Principal;
+import java.util.Enumeration;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.core.Configuration;
+import javax.ws.rs.core.SecurityContext;
+import org.glassfish.jersey.internal.MapPropertiesDelegate;
+import org.glassfish.jersey.server.ContainerRequest;
+import org.glassfish.jersey.server.internal.ContainerUtils;
+import org.glassfish.jersey.server.spi.ContainerResponseWriter;
+
+/**
+ * Utility methods for creating and populating a {@link
+ * org.glassfish.jersey.server.ContainerRequest} for use with Jersey {@link
+ * org.glassfish.jersey.server.ApplicationHandler}s
+ */
+public class ContainerRequestUtils {
+ private ContainerRequestUtils() {
+ /* Private ctor prevents instantiation */
+ }
+
+ // We don't rely on any of Jersey's authc/z features so we pass in this
empty context for
+ // all requests.
+ public static final SecurityContext DEFAULT_SECURITY_CONTEXT =
+ new SecurityContext() {
+ public boolean isUserInRole(String role) {
+ return false;
+ }
+
+ public boolean isSecure() {
+ return false;
+ }
+
+ public Principal getUserPrincipal() {
+ return null;
+ }
+
+ public String getAuthenticationScheme() {
+ return null;
+ }
+ };
+
+ /**
+ * Creates a {@link ContainerRequest}
+ *
+ * <p>Implementation guided by code in 'jersey-container-jetty-http's
JettyHttpContainer class.
+ */
+ public static ContainerRequest createContainerRequest(
+ HttpServletRequest httpServletRequest,
+ HttpServletResponse httpServletResponse,
+ Configuration appConfig) {
+ final ContainerResponseWriter responseWriter =
+ new JettyBridgeResponseWriter(httpServletResponse);
+ try {
+ final URI baseUri = getBaseUri(httpServletRequest);
+ final URI requestUri = getRequestUri(httpServletRequest, baseUri);
+ final ContainerRequest requestContext =
+ new ContainerRequest(
+ baseUri,
+ requestUri,
+ httpServletRequest.getMethod(),
+ DEFAULT_SECURITY_CONTEXT,
+ new MapPropertiesDelegate(),
+ appConfig);
+ requestContext.setEntityStream(httpServletRequest.getInputStream());
+ final Enumeration<String> headerNames =
httpServletRequest.getHeaderNames();
+ while (headerNames.hasMoreElements()) {
+ final String headerName = headerNames.nextElement();
+ String headerValue = httpServletRequest.getHeader(headerName);
+ requestContext.headers(headerName, headerValue == null ? "" :
headerValue);
+ }
+ requestContext.setWriter(responseWriter);
+ return requestContext;
+ } catch (Exception e) {
+ // TODO Should we handle URISyntaxException any differently here?
+ throw new RuntimeException(e);
+ }
+ }
+
+ private static URI getBaseUri(HttpServletRequest httpServletRequest) {
+ try {
+ return new URI(
+ httpServletRequest.getScheme(),
+ null,
+ httpServletRequest.getServerName(),
+ httpServletRequest.getServerPort(),
+ getBasePath(httpServletRequest),
+ null,
+ null);
+ } catch (final URISyntaxException ex) {
+ throw new IllegalArgumentException(ex);
+ }
+ }
+
+ private static String getBasePath(HttpServletRequest httpServletRequest) {
Review Comment:
*[UnusedVariable](https://errorprone.info/bugpattern/UnusedVariable):* The
parameter 'httpServletRequest' is never read.
---
```suggestion
getBasePath(),
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with
***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this
PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified
`file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see
its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new)
to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not
relevant](https://www.sonatype.com/lift-comment-rating?comment=329346832&lift_comment_rating=1)
] - [ [đ Won't
fix](https://www.sonatype.com/lift-comment-rating?comment=329346832&lift_comment_rating=2)
] - [ [đ Not critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=329346832&lift_comment_rating=3)
] - [ [đ Critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=329346832&lift_comment_rating=4)
] - [ [đ Critical, fixing
now](https://www.sonatype.com/lift-comment-rating?comment=329346832&lift_comment_rating=5)
]
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]