Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
[prod][1719415] Backwards compatible fix for https://issues.jboss.or…
Browse files Browse the repository at this point in the history
  • Loading branch information
spinder committed Jun 11, 2019
1 parent f338fea commit 62babaa
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.jboss.vfs.VFS;
import org.jboss.vfs.VFSUtils;
import org.jboss.vfs.VirtualFile;

/**
Expand Down Expand Up @@ -136,7 +138,12 @@ private List<UpdateFile> loadUpdateFiles() throws Exception {
}
} else if (resourceFolderURL.getProtocol().equals("vfs")) {
URLConnection conn = resourceFolderURL.openConnection();
VirtualFile virtualFolder = (VirtualFile)conn.getContent();
VirtualFile virtualFolder = null;
try {
virtualFolder = (VirtualFile) conn.getContent();
} catch (ClassCastException ex) {
virtualFolder = VFS.getChild(VFSUtils.toURI(resourceFolderURL));
}
for (VirtualFile virtualChild : virtualFolder.getChildren()) {
if (!virtualChild.isDirectory()) {
files.add(new UpdateFile(virtualChild.getPathNameRelativeTo(virtualFolder.getParent())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
Expand All @@ -38,6 +39,7 @@
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.Index;
import org.jboss.jandex.Indexer;
import org.jboss.vfs.VFS;
import org.jboss.vfs.VFSUtils;
import org.jboss.vfs.VirtualFile;
import org.jboss.vfs.VisitorAttributes;
Expand Down Expand Up @@ -160,9 +162,26 @@ private Set<String> loadPackagesNames() {
return Collections.emptySet();
}

VirtualFile virtualFile;
VirtualFile virtualFile = null;
try {
virtualFile = (VirtualFile) coreDomainPersistenceFileUrl.openConnection().getContent();
} catch (RuntimeException e) {
if (e instanceof ClassCastException) {
try {
Object content = coreDomainPersistenceFileUrl.openConnection().getContent();
if (content instanceof VirtualFile) {
virtualFile = (VirtualFile) coreDomainPersistenceFileUrl.openConnection().getContent();
} else {
virtualFile = VFS.getChild(VFSUtils.toURI(coreDomainPersistenceFileUrl));
}
} catch (IOException ex1) {
LOG.warn(WARNING_MESSAGE_LOAD_CLASSES, ex1);
return Collections.emptySet();
} catch (URISyntaxException ex2) {
LOG.warn(WARNING_MESSAGE_LOAD_CLASSES, ex2);
return Collections.emptySet();
}
}
} catch (IOException e) {
LOG.warn(WARNING_MESSAGE_LOAD_CLASSES, e);
return Collections.emptySet();
Expand Down

0 comments on commit 62babaa

Please sign in to comment.