• Bug
  • Status: Closed
  • 3 Minor
  • Resolution: Fixed
  • DSO:L1
  • hhuynh
  • Reporter: amiller
  • November 13, 2008
  • 0
  • Watchers: 0
  • April 10, 2009
  • March 05, 2009

Description

addClassResource() uses URL.equals() to compare URLs but this method actually does domain name resolution and blocks, so is a bad thing to rely on. See: http://michaelscharf.blogspot.com/2006/11/javaneturlequals-and-hashcode-make.html

On severity, I don’t see any obvious place where this method is actually used, so might be able to just remove it.

Comments

Tim Eck 2008-11-13

That method I think might be used from TIMs that do class exporting. I think only jar or file type URLs would really be passed here in reality, but it would be good to clean up the interface to make the issue impossible

Fiona OShea 2008-11-14

What do you want to do with this? Fix soon or later?

Fiona OShea 2008-12-12

If this can be done in 20mins or less go ahead.

Alex Miller 2009-03-05

Need to check whether this is used by any tims in the forge before removing. That’s unlikely but possible…if it is being used, please update this jira with that info so we can reassess.

Hung Huynh 2009-03-05

This method is used in TerracottaConfiguratorModule

protected final void addExportedBundleClass(final Bundle bundle, final String classname, final boolean targetSystemLoaderOnly) { String url = getBundleJarUrl(bundle) + ByteCodeUtil.classNameToFileName(classname); try { configHelper.addClassResource(classname, new URL(url), targetSystemLoaderOnly); } catch (MalformedURLException e) { throw new RuntimeException(“Unexpected error while constructing the URL ‘” + url + “’”, e); } }

which is under module-base project.

Are we still trying to delete it then? or trying to work around the URL.equals() call by converting the URL to String then compare that?

Hung Huynh 2009-03-05

converted URL to String before doing the comparision

if ((prev != null) && (!prev.getResource().toString().equals(resource.toString()))) {
  // we want to know if modules more than one module is trying to export the same class
  throw new AssertionError("Attempting to replace mapping for " + className + ", from " + prev + " to " + resource);
}