Changeset 10223 in josm
- Timestamp:
- 2016-05-16T04:05:58+02:00 (8 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/.settings/edu.umd.cs.findbugs.core.prefs
r10218 r10223 1 1 #FindBugs User Preferences 2 # Sun May 15 18:27:24CEST 20162 #Mon May 16 03:41:36 CEST 2016 3 3 cloud_id=edu.umd.cs.findbugs.cloud.doNothingCloud 4 4 detectorAppendingToAnObjectOutputStream=AppendingToAnObjectOutputStream|true … … 83 83 detectorInefficientIndexOf=InefficientIndexOf|true 84 84 detectorInefficientInitializationInsideLoop=InefficientInitializationInsideLoop|true 85 detectorInefficientMemberAccess=InefficientMemberAccess| true85 detectorInefficientMemberAccess=InefficientMemberAccess|false 86 86 detectorInefficientToArray=InefficientToArray|true 87 87 detectorInfiniteLoop=InfiniteLoop|true -
trunk/build.xml
r10222 r10223 676 676 excludeFilter="tools/findbugs/josm-filter.xml" 677 677 effort="max" 678 678 reportLevel="low" 679 679 > 680 680 <sourcePath path="${base.dir}/src" /> -
trunk/src/org/openstreetmap/josm/data/Preferences.java
r10212 r10223 1203 1203 structPrototype = klass.getConstructor().newInstance(); 1204 1204 } catch (ReflectiveOperationException ex) { 1205 throw new RuntimeException(ex);1205 throw new IllegalArgumentException(ex); 1206 1206 } 1207 1207 … … 1211 1211 continue; 1212 1212 } 1213 f.setAccessible(true);1213 Utils.setObjectsAccessible(f); 1214 1214 try { 1215 1215 Object fieldValue = f.get(struct); 1216 1216 Object defaultFieldValue = f.get(structPrototype); 1217 if (fieldValue != null) { 1218 if (f.getAnnotation(writeExplicitly.class) != null || !Objects.equals(fieldValue, defaultFieldValue)) { 1219 String key = f.getName().replace('_', '-'); 1220 if (fieldValue instanceof Map) { 1221 hash.put(key, mapToJson((Map) fieldValue)); 1222 } else if (fieldValue instanceof MultiMap) { 1223 hash.put(key, multiMapToJson((MultiMap) fieldValue)); 1224 } else { 1225 hash.put(key, fieldValue.toString()); 1226 } 1217 if (fieldValue != null && (f.getAnnotation(writeExplicitly.class) != null || !Objects.equals(fieldValue, defaultFieldValue))) { 1218 String key = f.getName().replace('_', '-'); 1219 if (fieldValue instanceof Map) { 1220 hash.put(key, mapToJson((Map<?, ?>) fieldValue)); 1221 } else if (fieldValue instanceof MultiMap) { 1222 hash.put(key, multiMapToJson((MultiMap<?, ?>) fieldValue)); 1223 } else { 1224 hash.put(key, fieldValue.toString()); 1227 1225 } 1228 1226 } 1229 } catch (IllegalA rgumentException | IllegalAccessException ex) {1227 } catch (IllegalAccessException ex) { 1230 1228 throw new RuntimeException(ex); 1231 1229 } … … 1261 1259 } catch (NoSuchFieldException ex) { 1262 1260 continue; 1263 } catch (SecurityException ex) {1264 throw new RuntimeException(ex);1265 1261 } 1266 1262 if (f.getAnnotation(pref.class) == null) { 1267 1263 continue; 1268 1264 } 1269 f.setAccessible(true);1265 Utils.setObjectsAccessible(f); 1270 1266 if (f.getType() == Boolean.class || f.getType() == boolean.class) { 1271 1267 value = Boolean.valueOf(key_value.getValue()); … … 1326 1322 try { 1327 1323 Field field = Toolkit.class.getDeclaredField("resources"); 1328 field.setAccessible(true);1324 Utils.setObjectsAccessible(field); 1329 1325 field.set(null, ResourceBundle.getBundle("sun.awt.resources.awt")); 1330 1326 } catch (ReflectiveOperationException e) { -
trunk/src/org/openstreetmap/josm/gui/PleaseWaitRunnable.java
r10212 r10223 25 25 */ 26 26 public abstract class PleaseWaitRunnable implements Runnable, CancelListener { 27 private boolean canceled;28 27 private boolean ignoreException; 29 28 private final String title; … … 150 149 @Override 151 150 public final void run() { 152 if (canceled)153 return; // since realRun isn't executed, do not call to finish154 155 151 if (EventQueue.isDispatchThread()) { 156 152 new Thread(new Runnable() { -
trunk/src/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationClient.java
r9935 r10223 91 91 if (provider != null) { 92 92 try { 93 // TODO 94 Field f = provider.getClass().getDeclaredField("connection"); 95 f.setAccessible(true); 93 Field f = provider.getClass().getDeclaredField("connection"); 94 Utils.setObjectsAccessible(f); 96 95 HttpURLConnection con = (HttpURLConnection) f.get(provider); 97 96 if (con != null) { -
trunk/src/org/openstreetmap/josm/gui/widgets/JosmImageView.java
r10046 r10223 17 17 import org.openstreetmap.josm.Main; 18 18 import org.openstreetmap.josm.tools.ImageProvider; 19 import org.openstreetmap.josm.tools.Utils; 19 20 20 21 /** … … 47 48 widthField = ImageView.class.getDeclaredField("width"); 48 49 heightField = ImageView.class.getDeclaredField("height"); 49 imageField.setAccessible(true); 50 stateField.setAccessible(true); 51 widthField.setAccessible(true); 52 heightField.setAccessible(true); 50 Utils.setObjectsAccessible(imageField, stateField, widthField, heightField); 53 51 } 54 52 … … 102 100 // And update the size params 103 101 Method updateImageSize = ImageView.class.getDeclaredMethod("updateImageSize"); 104 updateImageSize.setAccessible(true);102 Utils.setObjectsAccessible(updateImageSize); 105 103 updateImageSize.invoke(this); 106 104 } finally { … … 130 128 } else { 131 129 Method loadImage = ImageView.class.getDeclaredMethod("loadImage"); 132 loadImage.setAccessible(true);130 Utils.setObjectsAccessible(loadImage); 133 131 loadImage.invoke(this); 134 132 } -
trunk/src/org/openstreetmap/josm/io/Compression.java
r9720 r10223 96 96 * @throws IOException if any I/O error occurs 97 97 */ 98 @SuppressWarnings("resource")99 98 public static InputStream getUncompressedFileInputStream(File file) throws IOException { 100 return byExtension(file.getName()).getUncompressedInputStream(new FileInputStream(file)); 99 FileInputStream in = new FileInputStream(file); 100 try { 101 return byExtension(file.getName()).getUncompressedInputStream(in); 102 } catch (IOException e) { 103 Utils.close(in); 104 throw e; 105 } 101 106 } 102 107 … … 129 134 * @throws IOException if any I/O error occurs 130 135 */ 131 @SuppressWarnings("resource")132 136 public static OutputStream getCompressedFileOutputStream(File file) throws IOException { 133 return byExtension(file.getName()).getCompressedOutputStream(new FileOutputStream(file)); 137 FileOutputStream out = new FileOutputStream(file); 138 try { 139 return byExtension(file.getName()).getCompressedOutputStream(out); 140 } catch (IOException e) { 141 Utils.close(out); 142 throw e; 143 } 134 144 } 135 145 } -
trunk/src/org/openstreetmap/josm/io/OsmReader.java
r10212 r10223 11 11 import java.util.Collection; 12 12 import java.util.List; 13 import java.util.Objects; 13 14 import java.util.regex.Matcher; 14 15 import java.util.regex.Pattern; … … 355 356 } 356 357 // Read changeset info if neither upload-changeset nor id are set, or if they are both set to the same value 357 if ( id == uploadChangesetId || (id != null && id.equals(uploadChangesetId))) {358 if (Objects.equals(id, uploadChangesetId)) { 358 359 uploadChangeset = new Changeset(id != null ? id.intValue() : 0); 359 360 while (true) { -
trunk/src/org/openstreetmap/josm/tools/Diff.java
r10179 r10223 386 386 } 387 387 388 private boolean inhibit;389 390 388 /** 391 389 * Adjust inserts/deletes of blank lines to join changes as much as possible. 392 390 */ 393 391 private void shift_boundaries() { 394 if (inhibit)395 return;396 392 filevec[0].shift_boundaries(filevec[1]); 397 393 filevec[1].shift_boundaries(filevec[0]); -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r10066 r10223 26 26 import java.io.InputStreamReader; 27 27 import java.io.UnsupportedEncodingException; 28 import java.lang.reflect.AccessibleObject; 28 29 import java.net.MalformedURLException; 29 30 import java.net.URL; … … 34 35 import java.nio.file.Path; 35 36 import java.nio.file.StandardCopyOption; 37 import java.security.AccessController; 36 38 import java.security.MessageDigest; 37 39 import java.security.NoSuchAlgorithmException; 40 import java.security.PrivilegedAction; 38 41 import java.text.Bidi; 39 42 import java.text.MessageFormat; … … 1537 1540 } 1538 1541 1542 /** 1543 * Sets {@code AccessibleObject}(s) accessible. 1544 * @param objects objects 1545 * @see AccessibleObject#setAccessible 1546 * @since 10223 1547 */ 1548 public static void setObjectsAccessible(final AccessibleObject ... objects) { 1549 if (objects != null && objects.length > 0) { 1550 AccessController.doPrivileged(new PrivilegedAction<Object>() { 1551 @Override 1552 public Object run() { 1553 for (AccessibleObject o : objects) { 1554 o.setAccessible(true); 1555 } 1556 return null; 1557 } 1558 }); 1559 } 1560 } 1539 1561 }
Note:
See TracChangeset
for help on using the changeset viewer.