Skip to content

ResourceUtils.useCachesIfNecessary() not correct handle JNLP connections [SPR-9547] #14181

@spring-projects-issues

Description

@spring-projects-issues

Andreas Kuhtz opened SPR-9547 and commented

The following code should check if the connection is a JNLP connection.

/**
 * Set the {@link URLConnection#setUseCaches "useCaches"} flag on the
 * given connection, preferring <code>false</code> but leaving the
 * flag at <code>true</code> for JNLP based resources.
 * @param con the URLConnection to set the flag on
 */
public static void useCachesIfNecessary(URLConnection con) {
   con.setUseCaches(con.getClass().getName().startsWith("JNLP"));
}

I've debugged the code and the getName() of the connection returns the name with packages prefixed in case of using the Oracle JDK (as expected) what prevents the flag set to true.
I think this call should use ClassUtils.getShortName() instead of getClass().getName().

/**
 * Set the {@link URLConnection#setUseCaches "useCaches"} flag on the
 * given connection, preferring <code>false</code> but leaving the
 * flag at <code>true</code> for JNLP based resources.
 * @param con the URLConnection to set the flag on
 */
public static void useCachesIfNecessary(URLConnection con) {
   con.setUseCaches(ClassUtils.getShortName(con.getClass()).startsWith("JNLP"));
}

Affects: 3.1.1

Reference URL: http://forum.springsource.org/showthread.php?127798-ResourceUtils-and-JNLP

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions