test_class.declarator: LOG = LoggerFactory.getLogger(LicenseTest.class)
test_class.modifier: private static final
test_class.original_string: private static final Logger LOG = LoggerFactory.getLogger(LicenseTest.class);
test_class.type: Logger
test_class.var_name: LOG
test_class.file: rome-modules/src/test/java/com/rometools/modules/cc/types/LicenseTest.java
test_class.identifier: LicenseTest
test_case.body: @Test(timeout = 1000)
      public void testConcurrent() throws InterruptedException {
          final AtomicBoolean run = new AtomicBoolean(true);
          final AtomicLong type = new AtomicLong(0);
          // Tracking any problems.
          final AtomicBoolean hadProblem = new AtomicBoolean(false);
          final AtomicBoolean hadException = new AtomicBoolean(false);
  
          // This thread keeps on adding new licenses (not very realistic but shows the bug)
          final Thread addNew = new Thread() {
              @Override
              public void run() {
                  try {
                      while (run.get()) {
                          final License license = License.findByValue("http://creativecommons.org/licenses/" + type.incrementAndGet() + "/1");
                          if (license == null) {
                              hadProblem.set(true);
                          }
                      }
                  } catch (final Exception e) {
                      LOG.error("Exception in add-new thread", e);
                      hadException.set(true);
                  }
              }
          };
  
          // This thread attempts to get ones we know have already been put in.
          final Thread getExisting = new Thread() {
              @Override
              public void run() {
                  final Random rnd = new Random();
                  try {
                      while (run.get()) {
                          if (type.intValue() == 0) {
                              continue;
                          }
  
                          final License license = License.findByValue("http://creativecommons.org/licenses/" + rnd.nextInt(type.intValue()) + "/1");
                          if (license == null) {
                              hadProblem.set(true);
                          }
                      }
                  } catch (final Exception e) {
                      LOG.error("Exception in get-existing thread", e);
                      hadException.set(true);
                  }
              }
          };
  
          addNew.start();
          getExisting.start();
          // Let them do some stuff.
          Thread.sleep(400);
          // Get them to both stop.
          run.set(false);
          // Allow them a little time to stop.
          addNew.join(50);
          getExisting.join(50);
          // Check we didn't have any problems and they have both stopped.
          assertFalse(hadProblem.get());
          assertFalse(hadException.get());
          assertFalse(addNew.isAlive());
          assertFalse(getExisting.isAlive());
      }
test_case.class_method_signature: LicenseTest.testConcurrent()
test_case.full_signature: @Test(timeout = 1000) public void testConcurrent()
test_case.identifier: testConcurrent
test_case.invocations: get findByValue incrementAndGet set error set get intValue findByValue nextInt intValue set error set start start sleep set join join assertFalse get assertFalse get assertFalse isAlive assertFalse isAlive
test_case.modifiers: @Test(timeout = 1000) public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testConcurrent()
focal_class.declarator: CC_START = "http://creativecommons.org/licenses/"
focal_class.modifier: private static final
focal_class.original_string: private static final String CC_START = "http://creativecommons.org/licenses/";
focal_class.type: String
focal_class.var_name: CC_START
focal_class.declarator: lookupLicense = new ConcurrentHashMap<String, License>()
focal_class.modifier: private static final
focal_class.original_string: private static final Map<String, License> lookupLicense = new ConcurrentHashMap<String, License>();
focal_class.type: Map<String, License>
focal_class.var_name: lookupLicense
focal_class.declarator: LOG = LoggerFactory.getLogger(License.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOG = LoggerFactory.getLogger(License.class);
focal_class.type: Logger
focal_class.var_name: LOG
focal_class.declarator: NO_DERIVS = new License("http://creativecommons.org/licenses/nd/1.0/", new Behaviour[0], new Behaviour[] {
              Behaviour.DISTRIBUTION, Behaviour.REPRODUCTION})
focal_class.modifier: public static final
focal_class.original_string: public static final License NO_DERIVS = new License("http://creativecommons.org/licenses/nd/1.0/", new Behaviour[0], new Behaviour[] {
              Behaviour.DISTRIBUTION, Behaviour.REPRODUCTION});
focal_class.type: License
focal_class.var_name: NO_DERIVS
focal_class.declarator: NO_DERIVS_NONCOMMERCIAL = new License("http://creativecommons.org/licenses/nd-nc/1.0/",
              new Behaviour[] {Behaviour.NONCOMMERCIAL}, new Behaviour[] {Behaviour.DISTRIBUTION, Behaviour.REPRODUCTION})
focal_class.modifier: public static final
focal_class.original_string: public static final License NO_DERIVS_NONCOMMERCIAL = new License("http://creativecommons.org/licenses/nd-nc/1.0/",
              new Behaviour[] {Behaviour.NONCOMMERCIAL}, new Behaviour[] {Behaviour.DISTRIBUTION, Behaviour.REPRODUCTION});
focal_class.type: License
focal_class.var_name: NO_DERIVS_NONCOMMERCIAL
focal_class.declarator: NONCOMMERCIAL = new License("http://creativecommons.org/licenses/nc/1.0/", new Behaviour[] {Behaviour.NONCOMMERCIAL},
              new Behaviour[] {Behaviour.DERIVATIVE, Behaviour.DISTRIBUTION, Behaviour.REPRODUCTION})
focal_class.modifier: public static final
focal_class.original_string: public static final License NONCOMMERCIAL = new License("http://creativecommons.org/licenses/nc/1.0/", new Behaviour[] {Behaviour.NONCOMMERCIAL},
              new Behaviour[] {Behaviour.DERIVATIVE, Behaviour.DISTRIBUTION, Behaviour.REPRODUCTION});
focal_class.type: License
focal_class.var_name: NONCOMMERCIAL
focal_class.declarator: SHARE_ALIKE = new License("http://creativecommons.org/licenses/sa/1.0/", new Behaviour[] {Behaviour.COPYLEFT}, new Behaviour[] {
              Behaviour.DERIVATIVE, Behaviour.DISTRIBUTION, Behaviour.REPRODUCTION})
focal_class.modifier: public static final
focal_class.original_string: public static final License SHARE_ALIKE = new License("http://creativecommons.org/licenses/sa/1.0/", new Behaviour[] {Behaviour.COPYLEFT}, new Behaviour[] {
              Behaviour.DERIVATIVE, Behaviour.DISTRIBUTION, Behaviour.REPRODUCTION});
focal_class.type: License
focal_class.var_name: SHARE_ALIKE
focal_class.declarator: SHARE_ALIKE_NONCOMMERCIAL = new License("http://creativecommons.org/licenses/nc-sa/1.0/", new Behaviour[] {Behaviour.COPYLEFT,
              Behaviour.NONCOMMERCIAL}, new Behaviour[] {Behaviour.DERIVATIVE, Behaviour.DISTRIBUTION, Behaviour.REPRODUCTION})
focal_class.modifier: public static final
focal_class.original_string: public static final License SHARE_ALIKE_NONCOMMERCIAL = new License("http://creativecommons.org/licenses/nc-sa/1.0/", new Behaviour[] {Behaviour.COPYLEFT,
              Behaviour.NONCOMMERCIAL}, new Behaviour[] {Behaviour.DERIVATIVE, Behaviour.DISTRIBUTION, Behaviour.REPRODUCTION});
focal_class.type: License
focal_class.var_name: SHARE_ALIKE_NONCOMMERCIAL
focal_class.declarator: SHARE_ALIKE_ATTRIBUTION = new License("http://creativecommons.org/licenses/by-sa/2.5/", new Behaviour[] {Behaviour.COPYLEFT,
              Behaviour.ATTRIBUTION}, new Behaviour[] {Behaviour.DERIVATIVE, Behaviour.DISTRIBUTION, Behaviour.REPRODUCTION})
focal_class.modifier: public static final
focal_class.original_string: public static final License SHARE_ALIKE_ATTRIBUTION = new License("http://creativecommons.org/licenses/by-sa/2.5/", new Behaviour[] {Behaviour.COPYLEFT,
              Behaviour.ATTRIBUTION}, new Behaviour[] {Behaviour.DERIVATIVE, Behaviour.DISTRIBUTION, Behaviour.REPRODUCTION});
focal_class.type: License
focal_class.var_name: SHARE_ALIKE_ATTRIBUTION
focal_class.declarator: SHARE_ALIKE_NONCOMMERCIAL_ATTRIBUTION = new License("http://creativecommons.org/licenses/by-nc-sa/2.5/", new Behaviour[] {
              Behaviour.COPYLEFT, Behaviour.ATTRIBUTION, Behaviour.NONCOMMERCIAL}, new Behaviour[] {Behaviour.DERIVATIVE, Behaviour.DISTRIBUTION,
              Behaviour.REPRODUCTION})
focal_class.modifier: public static final
focal_class.original_string: public static final License SHARE_ALIKE_NONCOMMERCIAL_ATTRIBUTION = new License("http://creativecommons.org/licenses/by-nc-sa/2.5/", new Behaviour[] {
              Behaviour.COPYLEFT, Behaviour.ATTRIBUTION, Behaviour.NONCOMMERCIAL}, new Behaviour[] {Behaviour.DERIVATIVE, Behaviour.DISTRIBUTION,
              Behaviour.REPRODUCTION});
focal_class.type: License
focal_class.var_name: SHARE_ALIKE_NONCOMMERCIAL_ATTRIBUTION
focal_class.declarator: NONCOMMERCIAL_ATTRIBUTION = new License("http://creativecommons.org/licenses/by-nc/2.5/", new Behaviour[] {
              Behaviour.ATTRIBUTION, Behaviour.NONCOMMERCIAL}, new Behaviour[] {Behaviour.DERIVATIVE, Behaviour.DISTRIBUTION, Behaviour.REPRODUCTION})
focal_class.modifier: public static final
focal_class.original_string: public static final License NONCOMMERCIAL_ATTRIBUTION = new License("http://creativecommons.org/licenses/by-nc/2.5/", new Behaviour[] {
              Behaviour.ATTRIBUTION, Behaviour.NONCOMMERCIAL}, new Behaviour[] {Behaviour.DERIVATIVE, Behaviour.DISTRIBUTION, Behaviour.REPRODUCTION});
focal_class.type: License
focal_class.var_name: NONCOMMERCIAL_ATTRIBUTION
focal_class.declarator: NONCOMMERCIAL_ATTRIBUTION_NO_DERIVS = new License("http://creativecommons.org/licenses/by-nc-nd/2.5/", new Behaviour[] {
              Behaviour.ATTRIBUTION, Behaviour.NONCOMMERCIAL}, new Behaviour[] {Behaviour.DISTRIBUTION, Behaviour.REPRODUCTION})
focal_class.modifier: public static final
focal_class.original_string: public static final License NONCOMMERCIAL_ATTRIBUTION_NO_DERIVS = new License("http://creativecommons.org/licenses/by-nc-nd/2.5/", new Behaviour[] {
              Behaviour.ATTRIBUTION, Behaviour.NONCOMMERCIAL}, new Behaviour[] {Behaviour.DISTRIBUTION, Behaviour.REPRODUCTION});
focal_class.type: License
focal_class.var_name: NONCOMMERCIAL_ATTRIBUTION_NO_DERIVS
focal_class.declarator: ATTRIBUTION_NO_DERIVS = new License("http://creativecommons.org/licenses/by-nd/2.5/", new Behaviour[] {Behaviour.ATTRIBUTION},
              new Behaviour[] {Behaviour.DISTRIBUTION, Behaviour.REPRODUCTION})
focal_class.modifier: public static final
focal_class.original_string: public static final License ATTRIBUTION_NO_DERIVS = new License("http://creativecommons.org/licenses/by-nd/2.5/", new Behaviour[] {Behaviour.ATTRIBUTION},
              new Behaviour[] {Behaviour.DISTRIBUTION, Behaviour.REPRODUCTION});
focal_class.type: License
focal_class.var_name: ATTRIBUTION_NO_DERIVS
focal_class.declarator: ATTRIBUTION = new License("http://creativecommons.org/licenses/by/2.5/", new Behaviour[] {Behaviour.ATTRIBUTION},
              new Behaviour[] {Behaviour.DERIVATIVE, Behaviour.DISTRIBUTION, Behaviour.REPRODUCTION})
focal_class.modifier: public static final
focal_class.original_string: public static final License ATTRIBUTION = new License("http://creativecommons.org/licenses/by/2.5/", new Behaviour[] {Behaviour.ATTRIBUTION},
              new Behaviour[] {Behaviour.DERIVATIVE, Behaviour.DISTRIBUTION, Behaviour.REPRODUCTION});
focal_class.type: License
focal_class.var_name: ATTRIBUTION
focal_class.declarator: uri
focal_class.modifier: private final
focal_class.original_string: private final String uri;
focal_class.type: String
focal_class.var_name: uri
focal_class.declarator: permits
focal_class.modifier: private final
focal_class.original_string: private final Behaviour[] permits;
focal_class.type: Behaviour[]
focal_class.var_name: permits
focal_class.declarator: requires
focal_class.modifier: private final
focal_class.original_string: private final Behaviour[] requires;
focal_class.type: Behaviour[]
focal_class.var_name: requires
focal_class.file: rome-modules/src/main/java/com/rometools/modules/cc/types/License.java
focal_class.identifier: License
focal_class.class_method_signature: License.License(final String uri, final Behaviour[] requires, final Behaviour[] permits)
focal_class.full_signature: public  License(final String uri, final Behaviour[] requires, final Behaviour[] permits)
focal_class.identifier: License
focal_class.modifiers: public
focal_class.parameters: (final String uri, final Behaviour[] requires, final Behaviour[] permits)
focal_class.signature:  License(final String uri, final Behaviour[] requires, final Behaviour[] permits)
focal_class.class_method_signature: License.findByValue(final String uri)
focal_class.full_signature: public static License findByValue(final String uri)
focal_class.identifier: findByValue
focal_class.modifiers: public static
focal_class.parameters: (final String uri)
focal_class.return: License
focal_class.signature: License findByValue(final String uri)
focal_class.class_method_signature: License.clear()
focal_class.full_signature: static void clear()
focal_class.identifier: clear
focal_class.modifiers: static
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void clear()
focal_class.class_method_signature: License.getPermits()
focal_class.full_signature: public Behaviour[] getPermits()
focal_class.identifier: getPermits
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Behaviour[]
focal_class.signature: Behaviour[] getPermits()
focal_class.class_method_signature: License.getRequires()
focal_class.full_signature: public Behaviour[] getRequires()
focal_class.identifier: getRequires
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Behaviour[]
focal_class.signature: Behaviour[] getRequires()
focal_class.class_method_signature: License.toString()
focal_class.full_signature: @Override public String toString()
focal_class.identifier: toString
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String toString()
focal_class.class_method_signature: License.getValue()
focal_class.full_signature: public String getValue()
focal_class.identifier: getValue
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getValue()
focal_class.class_method_signature: License.equals(final Object obj)
focal_class.full_signature: @Override public boolean equals(final Object obj)
focal_class.identifier: equals
focal_class.modifiers: @Override public
focal_class.parameters: (final Object obj)
focal_class.return: boolean
focal_class.signature: boolean equals(final Object obj)
focal_class.class_method_signature: License.hashCode()
focal_class.full_signature: @Override public int hashCode()
focal_class.identifier: hashCode
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int hashCode()
focal_method.body: public static License findByValue(final String uri) {
          License found = License.lookupLicense.get(uri);
  
          // No I am going to try an guess about unknown licenses
          // This is try and match known CC licenses of other versions or various URLs to
          // current licenses, then make a new one with the same permissions.
          if (found == null && uri.startsWith("http://") && uri.toLowerCase().indexOf("creativecommons.org") != -1) {
              final Iterator<String> it = License.lookupLicense.keySet().iterator();
              while (it.hasNext() && found == null) {
                  final String key = it.next();
                  try {
                      if (key.startsWith(CC_START)) {
                          final String licensePath = key.substring(CC_START.length(), key.length());
                          final StringTokenizer tok = new StringTokenizer(licensePath, "/");
                          final String license = tok.nextToken();
                          // final String version = tok.nextToken();
                          if (uri.toLowerCase().indexOf("creativecommons.org/licenses/" + license) != -1) {
                              final License current = lookupLicense.get(key);
                              found = new License(uri, current.getRequires(), current.getPermits());
                          }
                      }
                  } catch (final Exception e) {
                      LOG.error("Error", e);
                  }
              }
          }
          // OK, we got here. If we haven't found a match, return a new License with unknown
          // permissions.
          if (found == null) {
              found = new License(uri, null, null);
          }
          return found;
      }
focal_method.class_method_signature: License.findByValue(final String uri)
focal_method.full_signature: public static License findByValue(final String uri)
focal_method.identifier: findByValue
focal_method.invocations: get startsWith indexOf toLowerCase iterator keySet hasNext next startsWith substring length length nextToken indexOf toLowerCase get getRequires getPermits error
focal_method.modifiers: public static
focal_method.parameters: (final String uri)
focal_method.return: License
focal_method.signature: License findByValue(final String uri)