JDK-4653036 : JarDiffHandler() should use javax.servlet.context.tempdir to store the jardiff
  • Type: Bug
  • Component: deploy
  • Sub-Component: webstart
  • Affected Version: 1.0.1
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2002-03-14
  • Updated: 2002-11-19
  • Resolved: 2002-11-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.2 mantisFixed
Description

Name: nt126004			Date: 03/14/2002


FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 [Versione 5.00.2195]

EXTRA RELEVANT SYSTEM CONFIGURATION :
CPU Intel Pentium III 733 Mhz, 512 Mhz Ram

A DESCRIPTION OF THE PROBLEM :
JarDiffHandler.generateJarDiff() does not read the context
attribute javax.servlet.context.tempdir, as it should, to
locate the temporary directory where to store the jardiff file.
It only relies on the system property java.io.tmpdir.
If it is not properly set, you will get a
java.io.IOException.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. set java.io.tmpdir to an unexistent directory
2. set the context attribute javax.servlet.context.tempdir
to a valid directory path
3. ask JnlpDownloadServlet to retrieve a jardiff file


EXPECTED VERSUS ACTUAL BEHAVIOR :
I expect the jardiff file as response from the
JnlpDownloadServlet, stored in the
javax.servlet.context.tempdir directory.

The Web Container raises a java.io.IOException.



ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.io.IOException: Impossibile trovare il percorso specificato
	at java.io.WinNTFileSystem.createFileExclusively(Native Method)
	at java.io.File.checkAndCreate(File.java:1294)
	at java.io.File.createTempFile(File.java:1382)
	at java.io.File.createTempFile(File.java:1419)
	at com.sysdata.lutest.test.doGet(test.java:38)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:247)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.StandardWrapperValve.invoke
(StandardWrapperValve.java:243)
	at org.apache.catalina.core.StandardPipeline.invokeNext
(StandardPipeline.java:566)
	at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:472)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
	at org.apache.catalina.core.StandardContextValve.invoke
(StandardContextValve.java:190)
	at org.apache.catalina.core.StandardPipeline.invokeNext
(StandardPipeline.java:566)
	at org.apache.catalina.valves.CertificatesValve.invoke
(CertificatesValve.java:246)
	at org.apache.catalina.core.StandardPipeline.invokeNext
(StandardPipeline.java:564)
	at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:472)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
	at org.apache.catalina.core.StandardContext.invoke
(StandardContext.java:2343)
	at org.apache.catalina.core.StandardHostValve.invoke
(StandardHostValve.java:180)
	at org.apache.catalina.core.StandardPipeline.invokeNext
(StandardPipeline.java:566)
	at org.apache.catalina.valves.ErrorDispatcherValve.invoke
(ErrorDispatcherValve.java:170)
	at org.apache.catalina.core.StandardPipeline.invokeNext
(StandardPipeline.java:564)
	at org.apache.catalina.valves.ErrorReportValve.invoke
(ErrorReportValve.java:170)
	at org.apache.catalina.core.StandardPipeline.invokeNext
(StandardPipeline.java:564)
	at org.apache.catalina.valves.AccessLogValve.invoke
(AccessLogValve.java:468)
	at org.apache.catalina.core.StandardPipeline.invokeNext
(StandardPipeline.java:564)
	at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:472)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
	at org.apache.catalina.core.StandardEngineValve.invoke
(StandardEngineValve.java:174)
	at org.apache.catalina.core.StandardPipeline.invokeNext
(StandardPipeline.java:566)
	at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:472)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
	at org.apache.catalina.connector.http.HttpProcessor.process
(HttpProcessor.java:1012)
	at org.apache.catalina.connector.http.HttpProcessor.run
(HttpProcessor.java:1107)
	at java.lang.Thread.run(Thread.java:536)


This bug can be reproduced always.

---------- BEGIN SOURCE ----------
I decompiled the JarDiffHandler class (I couldnt retrieve the sources).
The variable "file" (temporary directory path) is set but not used.


private File generateJarDiff(ResourceCatalog resourcecatalog, DownloadRequest
downloadrequest, JnlpResource jnlpresource)
    {
        DownloadRequest downloadrequest1 =
downloadrequest.getFromDownloadRequest();
        try
        {
            JnlpResource jnlpresource1 = resourcecatalog.lookupResource
(downloadrequest1);
            String s = _servletContext.getRealPath(jnlpresource.getPath());
            String s1 = _servletContext.getRealPath(jnlpresource1.getPath());
            if(s == null || s1 == null)
                return null;

            File file = (File)_servletContext.getAttribute
("javax.servlet.context.tempdir");

            File file1 = File.createTempFile("jnlp", ".jardiff");
            _log.addDebug("Generating Jardiff between " + s1 + " and " + s + "
Store in " + file1);

            FileOutputStream fileoutputstream = new FileOutputStream(file1);

            (new JarDiff()).createPatch(s1, s, fileoutputstream);

            fileoutputstream.close();

            if (file1.length() >= (new File(s)).length())
            {
                _log.addDebug("JarDiff discarded - since it is bigger");
                return null;
            } else
            {
                _log.addDebug("JarDiff generation succeeded");
                return file1;
            }
        }
        catch(IOException ioexception)
        {
            _log.addDebug("Failed to genereate jardiff", ioexception);
            return null;
        }
        catch(ErrorResponseException errorresponseexception)
        {
            _log.addDebug("Failed to genereate jardiff",
errorresponseexception);
        }
        return null;
    }

---------- END SOURCE ----------

CUSTOMER WORKAROUND :
Set the java.io.tmpdir to a valid directory path.
(Review ID: 143787) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mantis FIXED IN: mantis INTEGRATED IN: mantis mantis-b08
31-08-2004

EVALUATION investigate implementing this in mantis timeframe ###@###.### 2002-05-10
10-05-2002