Changeset 32976 in osm for applications/editors/josm


Ignore:
Timestamp:
2016-09-11T13:47:45+02:00 (8 years ago)
Author:
nokutu
Message:

Mor findbugs issues

Location:
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/io/download/MapillaryDownloader.java

    r32690 r32976  
    8181
    8282  /** All the Threads that have been run. Used to interrupt them properly. */
    83   private static List<Thread> threads = new ArrayList<>();
     83  //private static List<Thread> threads = new ArrayList<>();
    8484
    8585  /** Max area to be downloaded */
     
    130130  }
    131131
    132   private static void run(Thread t) {
    133     threads.add(t);
     132  private static void run(Runnable t) {
     133    //threads.add(t);
    134134    executor.execute(t);
    135135  }
     
    245245   */
    246246  public static void stopAll() {
    247     for (Thread t : threads) {
     247    /*for (Thread t : threads) {
    248248      if (t.isAlive())
    249249        Main.info(t+" is still alive!");
    250250      t.interrupt();
    251251    }
    252     threads.clear();
     252    threads.clear();*/
    253253    executor.shutdownNow();
    254254    try {
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/io/download/MapillarySquareDownloadManagerThread.java

    r31974 r32976  
    2626 * @see MapillaryTrafficSignDownloadThread
    2727 */
    28 public class MapillarySquareDownloadManagerThread extends Thread {
     28public class MapillarySquareDownloadManagerThread implements Runnable {
    2929
    3030  private final Bounds bounds;
    3131
    32   private final ThreadPoolExecutor downloadExecutor = new ThreadPoolExecutor(3, 5,
    33       25, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(5));
    34   private final ThreadPoolExecutor completeExecutor = new ThreadPoolExecutor(3, 5,
    35       25, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(5));
    36   private final ThreadPoolExecutor signsExecutor = new ThreadPoolExecutor(3, 5, 25,
    37       TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(5));
     32  private ThreadPoolExecutor downloadExecutor;
     33  private ThreadPoolExecutor completeExecutor;
     34  private ThreadPoolExecutor signsExecutor;
    3835
    3936  /**
     
    4946  @Override
    5047  public void run() {
     48    downloadExecutor = new ThreadPoolExecutor(3, 5,
     49      25, TimeUnit.SECONDS, new ArrayBlockingQueue<>(5));
     50    completeExecutor = new ThreadPoolExecutor(3, 5,
     51      25, TimeUnit.SECONDS, new ArrayBlockingQueue<>(5));
     52    signsExecutor = new ThreadPoolExecutor(3, 5, 25,
     53      TimeUnit.SECONDS, new ArrayBlockingQueue<>(5));
     54
    5155    try {
    5256      PluginState.startDownload();
     
    7781      this.downloadExecutor.execute(new MapillarySequenceDownloadThread(this.downloadExecutor, bounds, page));
    7882      while (this.downloadExecutor.getQueue().remainingCapacity() == 0) {
    79         Thread.sleep(500);
     83        Thread.sleep(100);
    8084      }
    8185      page++;
     
    120124    this.signsExecutor.awaitTermination(15, TimeUnit.SECONDS);
    121125  }
    122 
    123   @Override
    124   public void interrupt() {
    125     super.interrupt();
    126     this.downloadExecutor.shutdownNow();
    127     this.completeExecutor.shutdownNow();
    128     this.signsExecutor.shutdownNow();
    129     try {
    130       this.downloadExecutor.awaitTermination(15, TimeUnit.SECONDS);
    131       this.completeExecutor.awaitTermination(15, TimeUnit.SECONDS);
    132       this.signsExecutor.awaitTermination(15, TimeUnit.SECONDS);
    133     } catch (InterruptedException e) {
    134       Main.error(e);
    135     }
    136   }
    137126}
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/utils/ImageUtil.java

    r32975 r32976  
    4646      throw new IOException(f.getAbsolutePath() + " not found or not readable!");
    4747    } else if (f.isDirectory()) {
    48       for (File child : f.listFiles()) {
     48      File[] files = f.listFiles();
     49      assert files != null;
     50      for (File child : files) {
    4951        try {
    5052          images.addAll(readImagesFrom(child, defaultLL));
Note: See TracChangeset for help on using the changeset viewer.