karaf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF subversion and git services (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (KARAF-4802) Auto Deploy does not release resource
Date Thu, 12 Jan 2017 06:00:23 GMT

    [ https://issues.apache.org/jira/browse/KARAF-4802?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15820270#comment-15820270
] 

ASF subversion and git services commented on KARAF-4802:
--------------------------------------------------------

Commit c8deedeebb7fc867a30f0d74aa4413ffd21978e9 in karaf's branch refs/heads/karaf-4.0.x from
[~ffang]
[ https://git-wip-us.apache.org/repos/asf?p=karaf.git;h=c8deede ]

[KARAF-4802]Auto Deploy does not release resource

(cherry picked from commit e7f3071501314ea68dd330b671dff30717119eac)


> Auto Deploy does not release resource
> -------------------------------------
>
>                 Key: KARAF-4802
>                 URL: https://issues.apache.org/jira/browse/KARAF-4802
>             Project: Karaf
>          Issue Type: Bug
>          Components: karaf-core
>    Affects Versions: 4.0.5, 4.0.7
>         Environment: JDK 1.8.0_102 / Win10 (x64)
>            Reporter: Frederic ARNOUD
>            Assignee: Freeman Fang
>              Labels: leak
>   Original Estimate: 2h
>  Remaining Estimate: 2h
>
> *Calling getLastModified() opens the input stream.*
> In org.apache.karaf.deployer.blueprint-4.0.7-sources.jar:
> org/apache/karaf/deployer/blueprint/BlueprintTransformer.java:94:
>  	{{url.openConnection().getLastModified()}}
> 		=> calls {{sun.net.www.protocol.file.FileURLConnection#getLastModified()}}
> 		=> calls {{sun.net.www.protocol.file.FileURLConnection#initializeHeaders()}}
> 		=> calls {{sun.net.www.protocol.file.FileURLConnection#connect()}}
> 			in this function at line 57: {{this.connected}} is {{false}}
> 			and line 61: {{this.isDirectory}} is {{false}}
> 			*Here they open the input stream:*
> 			error source is at line 69: open input stream and keep it in this.is
> _Note:_
> There's a mistake at line (since they try to open the stream):
> 	sun/net/www/protocol/file/FileURLConnection.java:90 with a nice empty try/catch!
> AFAIK, there's no way to know if stream was open or not.
> I checked {{HttpURLConnection}}, it does the same (and {{HttpsURLConnection}} also).
> *IMHO you should add a function like this one (in BlueprintTransformer.java):*
> {code:java}
>     protected static long getLastModified(URL url) throws IOException {
>         URLConnection urlConnection = url.openConnection();
>         try(InputStream is = urlConnection.getInputStream()) {
>             return urlConnection.getLastModified();
>         }
>     }
> {code}
> To limit number of stream access, I did this in my code (in function similar to {{transform(URL,
OutputStream)}}):
> {code:java}
>         final URLConnection urlConnection = url.openConnection();
>         // keep original last modification date
>         final long lastModified = urlConnection.getLastModified();
>         try (InputStream in = urlConnection.getInputStream()) {
>             source = readAllBytes(in);
>         }
> {code}
> *Note:*
> When no object reference the InputStream, {{InputStream}} class will automatically close
the stream while processing finalizations.
> Before this process, we cannot delete file in deploy directory.
> (sorry I did not find component for this class)
> Same issue should appear in other deployers (not checked).



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message