mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 02:14:54 +00:00
close JsonParser where applicable to release internal jackson resources
This commit is contained in:
parent
ade36f026b
commit
bc217d99ce
7
.idea/libraries/jackson.xml
generated
7
.idea/libraries/jackson.xml
generated
@ -5,6 +5,11 @@
|
|||||||
<root url="jar://$GRADLE_REPOSITORY$/org.codehaus.jackson/jackson-mapper-asl/jars/jackson-mapper-asl-1.4.2.jar!/" />
|
<root url="jar://$GRADLE_REPOSITORY$/org.codehaus.jackson/jackson-mapper-asl/jars/jackson-mapper-asl-1.4.2.jar!/" />
|
||||||
</CLASSES>
|
</CLASSES>
|
||||||
<JAVADOC />
|
<JAVADOC />
|
||||||
<SOURCES />
|
<SOURCES>
|
||||||
|
<root url="file://$PROJECT_DIR$/../../../opt/jackson/1.4.2/src/java" />
|
||||||
|
<root url="file://$PROJECT_DIR$/../../../opt/jackson/1.4.2/src/mapper/java" />
|
||||||
|
<root url="file://$PROJECT_DIR$/../../../opt/jackson/1.4.2/src/xc/java" />
|
||||||
|
<root url="file://$PROJECT_DIR$/../../../opt/jackson/1.4.2/src/jaxrs/java" />
|
||||||
|
</SOURCES>
|
||||||
</library>
|
</library>
|
||||||
</component>
|
</component>
|
@ -252,8 +252,9 @@ public class JsonDocumentMapper implements DocumentMapper {
|
|||||||
}
|
}
|
||||||
type = this.type;
|
type = this.type;
|
||||||
|
|
||||||
|
JsonParser jp = null;
|
||||||
try {
|
try {
|
||||||
JsonParser jp = jsonFactory.createJsonParser(new FastStringReader(source));
|
jp = jsonFactory.createJsonParser(new FastStringReader(source));
|
||||||
jsonContext.reset(jp, new Document(), type, source);
|
jsonContext.reset(jp, new Document(), type, source);
|
||||||
|
|
||||||
// will result in JsonToken.START_OBJECT
|
// will result in JsonToken.START_OBJECT
|
||||||
@ -301,6 +302,14 @@ public class JsonDocumentMapper implements DocumentMapper {
|
|||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new MapperParsingException("Failed to parse", e);
|
throw new MapperParsingException("Failed to parse", e);
|
||||||
|
} finally {
|
||||||
|
if (jp != null) {
|
||||||
|
try {
|
||||||
|
jp.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return new ParsedDocument(jsonContext.uid(), jsonContext.id(), jsonContext.type(), jsonContext.doc(), source);
|
return new ParsedDocument(jsonContext.uid(), jsonContext.id(), jsonContext.type(), jsonContext.doc(), source);
|
||||||
}
|
}
|
||||||
|
@ -123,12 +123,22 @@ public class JsonIndexQueryParser extends AbstractIndexComponent implements Inde
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public Query parse(String source) throws QueryParsingException {
|
@Override public Query parse(String source) throws QueryParsingException {
|
||||||
|
JsonParser jp = null;
|
||||||
try {
|
try {
|
||||||
return parse(cache.get(), source, jsonFactory.createJsonParser(new FastStringReader(source)));
|
jp = jsonFactory.createJsonParser(new FastStringReader(source));
|
||||||
|
return parse(cache.get(), source, jp);
|
||||||
} catch (QueryParsingException e) {
|
} catch (QueryParsingException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new QueryParsingException(index, "Failed to parse [" + source + "]", e);
|
throw new QueryParsingException(index, "Failed to parse [" + source + "]", e);
|
||||||
|
} finally {
|
||||||
|
if (jp != null) {
|
||||||
|
try {
|
||||||
|
jp.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,7 +360,11 @@ public class JsonBuilder {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close() throws IOException {
|
public void close() {
|
||||||
generator.close();
|
try {
|
||||||
|
generator.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,11 @@ public class JsonSettingsLoader implements SettingsLoader {
|
|||||||
|
|
||||||
@Override public Map<String, String> load(String source) throws IOException {
|
@Override public Map<String, String> load(String source) throws IOException {
|
||||||
JsonParser jp = jsonFactory.createJsonParser(new FastStringReader(source));
|
JsonParser jp = jsonFactory.createJsonParser(new FastStringReader(source));
|
||||||
return load(jp);
|
try {
|
||||||
|
return load(jp);
|
||||||
|
} finally {
|
||||||
|
jp.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> load(JsonParser jp) throws IOException {
|
public Map<String, String> load(JsonParser jp) throws IOException {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user