Author: rombert
Date: Thu Jun 5 20:57:37 2014
New Revision: 1600759
URL: http://svn.apache.org/r1600759
Log:
SLING-3647 - No repository found at ... URL scheme http not supported.
only
Since the RepositoryProvider is not thread-safe, explicitly synchronize
access to it. This potentially fixes the bug, but it remains to be
validated.
Modified:
sling/trunk/tooling/ide/impl-vlt/src/org/apache/sling/ide/jcr/RepositoryUtils.java
Modified:
sling/trunk/tooling/ide/impl-vlt/src/org/apache/sling/ide/jcr/RepositoryUtils.java
URL:
http://svn.apache.org/viewvc/sling/trunk/tooling/ide/impl-vlt/src/org/apache/sling/ide/jcr/RepositoryUtils.java?rev=1600759&r1=1600758&r2=1600759&view=diff
==============================================================================
---
sling/trunk/tooling/ide/impl-vlt/src/org/apache/sling/ide/jcr/RepositoryUtils.java
(original)
+++
sling/trunk/tooling/ide/impl-vlt/src/org/apache/sling/ide/jcr/RepositoryUtils.java
Thu Jun 5 20:57:37 2014
@@ -31,36 +31,43 @@ import org.apache.sling.ide.transport.Re
public abstract class RepositoryUtils {
private static final RepositoryProvider REPOSITORY_PROVIDER = new
RepositoryProvider();
+ private static final Object SYNC = new Object();
private static final String[] WEBDAV_URL_LOCATIONS = new String[] {
"server/-/jcr:root", "crx/-/jcr:root" };
public static Repository getRepository(RepositoryInfo repositoryInfo)
throws RepositoryException {
-
- return
REPOSITORY_PROVIDER.getRepository(getRepositoryAddress(repositoryInfo));
+ synchronized (SYNC) {
+ return
REPOSITORY_PROVIDER.getRepository(getRepositoryAddress(repositoryInfo));
+ }
}
public static RepositoryAddress getRepositoryAddress(RepositoryInfo
repositoryInfo) {
StringBuilder errors = new StringBuilder();
for (String webDavUrlLocation : WEBDAV_URL_LOCATIONS) {
- Session session = null;
- try {
- // TODO proper error handling
+
+ Session session = null;
String url = repositoryInfo.getUrl() + webDavUrlLocation;
- RepositoryAddress address = new RepositoryAddress(url);
- Repository repository =
REPOSITORY_PROVIDER.getRepository(address);
- // TODO - this can be costly performance-wise ; we should
cache this information
- session = repository.login(new
SimpleCredentials(repositoryInfo.getUsername(), repositoryInfo
- .getPassword().toCharArray()));
- return address;
- } catch (URISyntaxException e) {
- throw new RuntimeException(e);
- } catch (RepositoryException e) {
- errors.append(webDavUrlLocation).append(" :
").append(e.getMessage()).append('\n');
- continue;
- } finally {
- if (session != null) {
- session.logout();
+ try {
+ // TODO proper error handling
+ RepositoryAddress address = new RepositoryAddress(url);
+ Repository repository;
+ synchronized (SYNC) {
+ repository =
REPOSITORY_PROVIDER.getRepository(address);
+ }
+
+ // TODO - this can be costly performance-wise ; we should
cache this information
+ session = repository.login(new
SimpleCredentials(repositoryInfo.getUsername(), repositoryInfo
+ .getPassword().toCharArray()));
+ return address;
+ } catch (URISyntaxException e) {
+ throw new RuntimeException(e);
+ } catch (RepositoryException e) {
+ errors.append(url).append(" :
").append(e.getMessage()).append('\n');
+ continue;
+ } finally {
+ if (session != null) {
+ session.logout();
+ }
}
- }
}
errors.deleteCharAt(errors.length() - 1);