Rethrow RuntimeExceptions and Errors that appear while reading a URL.
authorJan Lahoda <jlahoda@netbeans.org>
Tue, 10 Jul 2012 21:12:29 +0200
changeset 8233ed9d490fb91
parent 822 77592a5f7e76
child 824 22e809871308
Rethrow RuntimeExceptions and Errors that appear while reading a URL.
remoting/ide/api/src/org/netbeans/modules/jackpot30/remoting/api/WebUtilities.java
     1.1 --- a/remoting/ide/api/src/org/netbeans/modules/jackpot30/remoting/api/WebUtilities.java	Tue Jul 10 20:47:26 2012 +0200
     1.2 +++ b/remoting/ide/api/src/org/netbeans/modules/jackpot30/remoting/api/WebUtilities.java	Tue Jul 10 21:12:29 2012 +0200
     1.3 @@ -74,6 +74,8 @@
     1.4  
     1.5      public static @CheckForNull String requestStringResponse (final URI uri, AtomicBoolean cancel) {
     1.6          final String[] result = new String[1];
     1.7 +        final RuntimeException[] re = new RuntimeException[1];
     1.8 +        final Error[] err = new Error[1];
     1.9          Task task = LOADER.create(new Runnable() {
    1.10              @Override
    1.11              public void run() {
    1.12 @@ -99,6 +101,10 @@
    1.13              result[0] = sb.toString();
    1.14          } catch (IOException e) {
    1.15              Logger.getLogger(WebUtilities.class.getName()).log(Level.INFO, uri.toASCIIString(), e);
    1.16 +        } catch (RuntimeException ex) {
    1.17 +            re[0] = ex;
    1.18 +        } catch (Error ex) {
    1.19 +            err[0] = ex;
    1.20          }
    1.21              }
    1.22          });
    1.23 @@ -107,7 +113,11 @@
    1.24          
    1.25          while (!cancel.get()) {
    1.26              try {
    1.27 -                if (task.waitFinished(1000)) return result[0];
    1.28 +                if (task.waitFinished(1000)) {
    1.29 +                    if (re[0] != null) throw re[0];
    1.30 +                    else if (err[0] != null) throw err[0];
    1.31 +                    else return result[0];
    1.32 +                }
    1.33              } catch (InterruptedException ex) {
    1.34                  Logger.getLogger(WebUtilities.class.getName()).log(Level.FINE, null, ex);
    1.35              }