[jboss-jira] [JBoss JIRA] (JBVFS-207) Provide way to retrieve VirtualFile instance from url.openConnection()
Tomas Hofman (Jira)
issues at jboss.org
Tue Nov 6 07:55:00 EST 2018
[ https://issues.jboss.org/browse/JBVFS-207?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13657162#comment-13657162 ]
Tomas Hofman edited comment on JBVFS-207 at 11/6/18 7:54 AM:
-------------------------------------------------------------
PRs: https://github.com/jbossas/jboss-vfs/pull/30, https://github.com/jbossas/jboss-vfs/pull/31
was (Author: thofman):
PR: https://github.com/jbossas/jboss-vfs/pull/30
> Provide way to retrieve VirtualFile instance from url.openConnection()
> ----------------------------------------------------------------------
>
> Key: JBVFS-207
> URL: https://issues.jboss.org/browse/JBVFS-207
> Project: JBoss VFS
> Issue Type: Enhancement
> Reporter: Tomas Hofman
> Assignee: Tomas Hofman
> Priority: Major
>
> It is not possible to obtain VirtualFile (and by extensions it's physicalFile) instance wrapped in VirtualFileURLConnection without using reflection.
> Code snippet from Drools [1], where they try to get hold of {{VirtualFile#getPhysicalFile()}}:
> {code}
> private static Object findVirtualFile( URL url ) throws IOException {
> URLConnection urlConnection = url.openConnection();
> try {
> if ( urlConnection.getClass().getName().equals( "org.jboss.vfs.protocol.VirtualFileURLConnection" ) ) {
> Field f = urlConnection.getClass().getDeclaredField( "file" );
> f.setAccessible( true );
> return f.get( urlConnection );
> }
> } catch (NoSuchFieldException | IllegalAccessException e) {
> // ignored
> }
> return urlConnection.getContent();
> }
> {code}
> [1] https://github.com/kiegroup/drools/commit/2a36f67a29ed06d0f980a60ff1c81fa897e8147a
--
This message was sent by Atlassian Jira
(v7.12.1#712002)
More information about the jboss-jira
mailing list