[jboss-jira] [JBoss JIRA] (WFLY-11567) Provide way to retrieve VirtualFile instance from url.openConnection()
Richard Opalka (Jira)
issues at jboss.org
Mon Dec 2 07:43:01 EST 2019
[ https://issues.jboss.org/browse/WFLY-11567?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Richard Opalka resolved WFLY-11567.
-----------------------------------
Resolution: Done
> Provide way to retrieve VirtualFile instance from url.openConnection()
> ----------------------------------------------------------------------
>
> Key: WFLY-11567
> URL: https://issues.jboss.org/browse/WFLY-11567
> Project: WildFly
> Issue Type: Enhancement
> Components: VFS
> Reporter: Tomas Hofman
> Assignee: Tomas Hofman
> Priority: Major
> Fix For: 19.0.0.Beta1
>
>
> 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.13.8#713008)
More information about the jboss-jira
mailing list