View Javadoc
1   /*
2    * Copyright (C) 2005-2015 Schlichtherle IT Services.
3    * All rights reserved. Use is subject to license terms.
4    */
5   package de.schlichtherle.truezip.fs;
6   
7   import java.io.IOException;
8   import javax.annotation.concurrent.ThreadSafe;
9   
10  /**
11   * Indicates that a call to {@link FsController#sync} cannot succeed because
12   * some threads have unclosed I/O resources, e.g. streams or channels.
13   * <p>
14   * This exception should be recoverable, meaning it should be possible to
15   * successfully retry the operation as soon as these I/O resources have been
16   * closed and no other exceptional conditions apply.
17   * 
18   * @since   TrueZIP 7.5
19   * @author  Christian Schlichtherle
20   */
21  @ThreadSafe
22  public final class FsResourceOpenException extends IOException {
23      private static final long serialVersionUID = 1L;
24  
25      final int local, total;
26  
27      FsResourceOpenException(int total, int local) {
28          super("Thread-local / total number of open I/O resources (streams, channels etc): %d / %d");
29          this.local = local;
30          this.total = total;
31      }
32  
33      public int getLocal() { return local; }
34  
35      public int getTotal() { return total; }
36  
37      @Override
38      public String getMessage() {
39          return String.format(super.getMessage(), local, total);
40      }
41  }