Skip to content

Commit

Permalink
ATLAS-4461: DSL Search : DSL Search with only typename throws NPE
Browse files Browse the repository at this point in the history
Signed-off-by: Sidharth Mishra <[email protected]>
  • Loading branch information
rkundam authored and sidharthkmishra committed Oct 26, 2021
1 parent f08003d commit a5ffaae
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,16 @@ public AtlasSearchResult searchUsingDSL(@QueryParam("query") String que
Servlets.validateQueryParamLength("typeName", typeName);
Servlets.validateQueryParamLength("classification", classification);

if (StringUtils.isNotEmpty(query) && query.length() > maxDslQueryLength) {
throw new AtlasBaseException(AtlasErrorCode.INVALID_QUERY_LENGTH, Constants.MAX_DSL_QUERY_STR_LENGTH);
if (StringUtils.isNotEmpty(query)) {
if (query.length() > maxDslQueryLength) {
throw new AtlasBaseException(AtlasErrorCode.INVALID_QUERY_LENGTH, Constants.MAX_DSL_QUERY_STR_LENGTH);
}
query = Servlets.decodeQueryString(query);
}

AtlasPerfTracer perf = null;

try {

query = Servlets.decodeQueryString(query);

if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "DiscoveryREST.searchUsingDSL(" + query + "," + typeName
+ "," + classification + "," + limit + "," + offset + ")");
Expand Down
10 changes: 7 additions & 3 deletions webapp/src/main/java/org/apache/atlas/web/util/Servlets.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,12 @@ public static void validateQueryParamLength(String paramName, String paramValue)
}
}

public static String decodeQueryString(String query) {
return UriUtils.decode(query,"UTF-8");

public static String decodeQueryString(String query) throws AtlasBaseException {
try {
return UriUtils.decode(query,"UTF-8");
} catch (Exception e) {
LOG.error("Error occurred while decoding query:" + query, e.getMessage());
throw new AtlasBaseException(e.getMessage());
}
}
}

0 comments on commit a5ffaae

Please sign in to comment.