Move decode method before calling acquireSegment to avoid reference count leak
@@ -259,24 +259,24 @@ public class TablesResource {
@ApiParam(value = "Segment name", required = true) @PathParam("segmentName") String segmentName,
@ApiParam(value = "Column name", allowMultiple = true) @QueryParam("columns") @DefaultValue("")
List<String> columns) {
- TableDataManager tableDataManager = ServerResourceUtils.checkGetTableDataManager(_serverInstance, tableName);
+ for (int i = 0; i < columns.size(); i++) {
try {
- segmentName = URLDecoder.decode(segmentName, StandardCharsets.UTF_8.name());
+ columns.set(i, URLDecoder.decode(columns.get(i), StandardCharsets.UTF_8.name()));
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e.getCause());
}
- SegmentDataManager segmentDataManager = tableDataManager.acquireSegment(segmentName);
- if (segmentDataManager == null) {
- throw new WebApplicationException(String.format("Table %s segments %s does not exist", tableName, segmentName),
- Response.Status.NOT_FOUND);
}
- for (int i = 0; i < columns.size(); i++) {
+ TableDataManager tableDataManager = ServerResourceUtils.checkGetTableDataManager(_serverInstance, tableName);
try {
- columns.set(i, URLDecoder.decode(columns.get(i), StandardCharsets.UTF_8.name()));
+ segmentName = URLDecoder.decode(segmentName, StandardCharsets.UTF_8.name());
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e.getCause());
}
+ SegmentDataManager segmentDataManager = tableDataManager.acquireSegment(segmentName);
+ if (segmentDataManager == null) {
+ throw new WebApplicationException(String.format("Table %s segments %s does not exist", tableName, segmentName),
+ Response.Status.NOT_FOUND);
}
try {
