kopia lustrzana https://github.com/JOSM/MapWithAI
DataConflationSender: Fix some sonar issues
Signed-off-by: Taylor Smock <tsmock@fb.com>pull/1/head
rodzic
960798c9ca
commit
99d1b61ab9
|
@ -67,23 +67,25 @@ public class DataConflationSender implements RunnableFuture<DataSet> {
|
|||
public void run() {
|
||||
String url = MapWithAIConflationCategory.conflationUrlFor(category);
|
||||
this.client = HttpClients.createDefault();
|
||||
try (CloseableHttpClient client = this.client) {
|
||||
StringWriter output = new StringWriter();
|
||||
OsmWriter writer = OsmWriterFactory.createOsmWriter(new PrintWriter(output), true, "0.6");
|
||||
try (CloseableHttpClient currentClient = this.client) {
|
||||
MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder.create();
|
||||
if (osm != null) {
|
||||
StringWriter output = new StringWriter();
|
||||
try (OsmWriter writer = OsmWriterFactory.createOsmWriter(new PrintWriter(output), true, "0.6")) {
|
||||
writer.write(osm);
|
||||
multipartEntityBuilder.addTextBody("openstreetmap", output.toString(), ContentType.APPLICATION_XML);
|
||||
}
|
||||
}
|
||||
// We need to reset the writers to avoid writing previous streams
|
||||
output = new StringWriter();
|
||||
writer = OsmWriterFactory.createOsmWriter(new PrintWriter(output), true, "0.6");
|
||||
StringWriter output = new StringWriter();
|
||||
try (OsmWriter writer = OsmWriterFactory.createOsmWriter(new PrintWriter(output), true, "0.6")) {
|
||||
writer.write(external);
|
||||
multipartEntityBuilder.addTextBody("external", output.toString(), ContentType.APPLICATION_XML);
|
||||
}
|
||||
HttpEntity postData = multipartEntityBuilder.build();
|
||||
HttpUriRequest request = RequestBuilder.post(url).setEntity(postData).build();
|
||||
|
||||
HttpResponse response = client.execute(request);
|
||||
HttpResponse response = currentClient.execute(request);
|
||||
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
|
||||
conflatedData = OsmReader.parseDataSet(response.getEntity().getContent(), NullProgressMonitor.INSTANCE,
|
||||
OsmReader.Options.SAVE_ORIGINAL_ID);
|
||||
|
|
Ładowanie…
Reference in New Issue