Changeset 15588 in josm for trunk/src/org
- Timestamp:
- 2019-12-13T22:12:24+01:00 (5 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/JosmAction.java
r15521 r15588 279 279 SelectionEventManager.getInstance().removeSelectionListener(selectionChangeAdapter); 280 280 } 281 MainApplication.getToolbar().unregister(this); 281 if (MainApplication.getToolbar() != null) { 282 MainApplication.getToolbar().unregister(this); 283 } 282 284 } 283 285 -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r15586 r15588 778 778 return Stream.empty(); 779 779 } 780 final Stream<OsmPrimitive> stream = referrers instanceof OsmPrimitive 780 final Stream<OsmPrimitive> stream = referrers instanceof OsmPrimitive // NOPMD 781 781 ? Stream.of((OsmPrimitive) referrers) 782 782 : Arrays.stream((OsmPrimitive[]) referrers); -
trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java
r15485 r15588 108 108 */ 109 109 @SuppressWarnings("unchecked") 110 private static final Class<Test>[] CORE_TEST_CLASSES = new Class[] { 110 private static final Class<Test>[] CORE_TEST_CLASSES = new Class[] {// NOPMD 111 111 /* FIXME - unique error numbers for tests aren't properly unique - ignoring will not work as expected */ 112 112 DuplicateNode.class, // ID 1 .. 99 -
trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java
r15586 r15588 391 391 final MapCSSStyleSource source = new MapCSSStyleSource(""); 392 392 final MapCSSParser preprocessor = new MapCSSParser(css, MapCSSParser.LexicalState.PREPROCESSOR); 393 final StringReader mapcss = new StringReader(preprocessor.pp_root(source));394 final MapCSSParser parser = new MapCSSParser(mapcss, MapCSSParser.LexicalState.DEFAULT);395 parser.sheet(source);393 try (StringReader mapcss = new StringReader(preprocessor.pp_root(source))) { 394 new MapCSSParser(mapcss, MapCSSParser.LexicalState.DEFAULT).sheet(source); 395 } 396 396 // Ignore "meta" rule(s) from external rules of JOSM wiki 397 397 source.removeMetaRules(); -
trunk/src/org/openstreetmap/josm/gui/dialogs/MapPaintDialog.java
r15492 r15588 634 634 p.add(new JScrollPane(txtSource), GBC.std().fill()); 635 635 636 try { 637 InputStream is = s.getSourceInputStream(); 638 try (BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) { 639 String line; 640 while ((line = reader.readLine()) != null) { 641 txtSource.append(line + '\n'); 642 } 643 } finally { 644 s.closeSourceInputStream(is); 645 } 636 try (BufferedReader reader = new BufferedReader(new InputStreamReader(s.getSourceInputStream(), StandardCharsets.UTF_8))) { 637 reader.lines().forEach(line -> txtSource.append(line + '\n')); 646 638 } catch (IOException ex) { 647 639 Logging.error(ex); -
trunk/src/org/openstreetmap/josm/gui/io/CustomConfigurator.java
r14624 r15588 689 689 String fragmentWithReplacedVars = evalVars(outputWriter.toString()); 690 690 691 CharArrayReader reader = new CharArrayReader(fragmentWithReplacedVars.toCharArray()); 692 tmpPref.fromXML(reader); 691 try (CharArrayReader reader = new CharArrayReader(fragmentWithReplacedVars.toCharArray())) { 692 tmpPref.fromXML(reader); 693 } 693 694 } catch (TransformerException | XMLStreamException | IOException ex) { 694 695 PreferencesUtils.log(ex, "Error: can not read XML fragment:"); -
trunk/src/org/openstreetmap/josm/gui/io/importexport/GeoJSONImporter.java
r15427 r15588 71 71 public DataSet parseDataSet(final String source) throws IOException, IllegalDataException { 72 72 try (CachedFile cf = new CachedFile(source)) { 73 InputStream fileInputStream = Compression.getUncompressedFileInputStream(cf.getFile()); 73 InputStream fileInputStream = Compression.getUncompressedFileInputStream(cf.getFile()); // NOPMD 74 74 return GeoJSONReader.parseDataSet(fileInputStream, NullProgressMonitor.INSTANCE); 75 75 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSource.java
r15289 r15588 433 433 // evaluate @media { ... } blocks 434 434 MapCSSParser preprocessor = new MapCSSParser(reader, MapCSSParser.LexicalState.PREPROCESSOR); 435 String mapcss = preprocessor.pp_root(this);436 435 437 436 // do the actual mapcss parsing 438 Reader in2 = new StringReader(mapcss);439 MapCSSParser parser = new MapCSSParser(in2, MapCSSParser.LexicalState.DEFAULT);440 parser.sheet(this);437 try (Reader in2 = new StringReader(preprocessor.pp_root(this))) { 438 new MapCSSParser(in2, MapCSSParser.LexicalState.DEFAULT).sheet(this); 439 } 441 440 442 441 loadMeta(); -
trunk/src/org/openstreetmap/josm/io/BoundingBoxDownloader.java
r15447 r15588 218 218 CheckParameterUtil.ensureThat(daysClosed >= -1, "Requested note limit is less than -1."); 219 219 String url = "notes?limit=" + noteLimit + "&closed=" + daysClosed + "&bbox=" + lon1 + ',' + lat1 + ',' + lon2 + ',' + lat2; 220 try { 221 InputStream is = getInputStream(url, progressMonitor.createSubTaskMonitor(1, false)); 222 NoteReader reader = new NoteReader(is); 223 final List<Note> notes = reader.parse(); 220 try (InputStream is = getInputStream(url, progressMonitor.createSubTaskMonitor(1, false))) { 221 final List<Note> notes = new NoteReader(is).parse(); 224 222 if (notes.size() == noteLimit) { 225 223 throw new MoreNotesException(notes, noteLimit); -
trunk/src/org/openstreetmap/josm/io/CachedFile.java
r15416 r15588 347 347 Pair<String, InputStream> res = null; 348 348 try { 349 ZipFile zipFile = new ZipFile(file, StandardCharsets.UTF_8); 349 ZipFile zipFile = new ZipFile(file, StandardCharsets.UTF_8); // NOPMD 350 350 ZipEntry resentry = null; 351 351 Enumeration<? extends ZipEntry> entries = zipFile.entries(); … … 358 358 } 359 359 if (resentry != null) { 360 InputStream is = zipFile.getInputStream(resentry); 360 InputStream is = zipFile.getInputStream(resentry); // NOPMD 361 361 res = Pair.create(resentry.getName(), is); 362 362 } else { -
trunk/src/org/openstreetmap/josm/io/Compression.java
r14979 r15588 177 177 public static InputStream getUncompressedFileInputStream(File file) throws IOException { 178 178 try { 179 InputStream in = Files.newInputStream(file.toPath()); 179 InputStream in = Files.newInputStream(file.toPath()); // NOPMD 180 180 try { 181 181 return byExtension(file.getName()).getUncompressedInputStream(in); … … 221 221 */ 222 222 public static OutputStream getCompressedFileOutputStream(File file) throws IOException { 223 OutputStream out = Files.newOutputStream(file.toPath()); 223 OutputStream out = Files.newOutputStream(file.toPath()); // NOPMD 224 224 try { 225 225 return byExtension(file.getName()).getCompressedOutputStream(out); -
trunk/src/org/openstreetmap/josm/io/GpxReader.java
r15497 r15588 621 621 */ 622 622 public GpxReader(InputStream source) throws IOException { 623 Reader utf8stream = UTFInputStreamReader.create(source); 624 Reader filtered = new InvalidXmlCharacterFilter(utf8stream); 623 Reader utf8stream = UTFInputStreamReader.create(source); // NOPMD 624 Reader filtered = new InvalidXmlCharacterFilter(utf8stream); // NOPMD 625 625 this.inputSource = new InputSource(filtered); 626 626 } -
trunk/src/org/openstreetmap/josm/io/OsmServerLocationReader.java
r15247 r15588 144 144 protected final <T> T doParse(Parser<T> parser, final ProgressMonitor progressMonitor) throws OsmTransferException { 145 145 progressMonitor.beginTask(tr("Contacting Server...", 10)); 146 try { 146 try { // NOPMD 147 147 return parser.parse(); 148 148 } catch (OsmTransferException e) { … … 211 211 return null; 212 212 progressMonitor.subTask(tr("Downloading OSM data...")); 213 InputStream uncompressedInputStream = compression.getUncompressedInputStream(in); 213 InputStream uncompressedInputStream = compression.getUncompressedInputStream(in); // NOPMD 214 214 ProgressMonitor subTaskMonitor = progressMonitor.createSubTaskMonitor(1, false); 215 215 if ("application/json".equals(contentType)) { -
trunk/src/org/openstreetmap/josm/io/remotecontrol/RemoteControlHttpServer.java
r12846 r15588 102 102 try { 103 103 @SuppressWarnings("resource") 104 Socket request = server.accept(); 104 Socket request = server.accept(); // NOPMD 105 105 RequestProcessor.processRequest(request); 106 106 } catch (SocketException e) { -
trunk/src/org/openstreetmap/josm/io/remotecontrol/RequestProcessor.java
r15507 r15588 6 6 import java.io.IOException; 7 7 import java.io.InputStreamReader; 8 import java.io.OutputStream;9 8 import java.io.OutputStreamWriter; 10 9 import java.io.PrintWriter; … … 20 19 import java.util.Map; 21 20 import java.util.Map.Entry; 21 import java.util.Objects; 22 22 import java.util.Optional; 23 23 import java.util.StringTokenizer; … … 86 86 super("RemoteControl request processor"); 87 87 this.setDaemon(true); 88 this.request = request;88 this.request = Objects.requireNonNull(request); 89 89 } 90 90 … … 94 94 */ 95 95 public static void processRequest(Socket request) { 96 RequestProcessor processor = new RequestProcessor(request); 97 processor.start(); 96 new RequestProcessor(request).start(); 98 97 } 99 98 … … 167 166 @Override 168 167 public void run() { 169 Writer out = null; 170 try { 171 OutputStream raw = new BufferedOutputStream(request.getOutputStream()); 172 out = new OutputStreamWriter(raw, RESPONSE_CHARSET); 173 BufferedReader in = new BufferedReader(new InputStreamReader(request.getInputStream(), "ASCII")); 168 Writer out = null; // NOPMD 169 try { // NOPMD 170 out = new OutputStreamWriter(new BufferedOutputStream(request.getOutputStream()), RESPONSE_CHARSET); 171 BufferedReader in = new BufferedReader(new InputStreamReader(request.getInputStream(), "ASCII")); // NOPMD 174 172 175 173 String get = in.readLine(); … … 274 272 } 275 273 } 276 277 274 } catch (IOException ioe) { 278 275 Logging.debug(Logging.getErrorMessage(ioe)); … … 423 420 } 424 421 425 PrintWriter r = new PrintWriter(w); 426 printJsonInfo(cmd, r, handler); 427 return w.toString(); 422 try (PrintWriter r = new PrintWriter(w)) { 423 printJsonInfo(cmd, r, handler); 424 return w.toString(); 425 } 428 426 } catch (IOException e) { 429 427 Logging.error(e); -
trunk/src/org/openstreetmap/josm/plugins/PluginListParser.java
r14189 r15588 59 59 public List<PluginInformation> parse(InputStream in) throws PluginListParseException { 60 60 List<PluginInformation> ret = new LinkedList<>(); 61 BufferedReader r = null; 62 try { 63 r = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8)); 61 try (BufferedReader r = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8))) { 64 62 String name = null; 65 63 String url = null; … … 85 83 url = x[1]; 86 84 manifest = new StringBuilder(); 87 88 85 } 89 86 addPluginInformation(ret, name, url, manifest.toString());
Note:
See TracChangeset
for help on using the changeset viewer.