mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
Maven: do not try to update broken indices repeatedly, UnsupportedExistingIndicesException fixed (IDEA-67512)
This commit is contained in:
@@ -66,7 +66,7 @@ public class MavenId implements Serializable {
|
||||
|
||||
public static void append(StringBuilder builder, String part) {
|
||||
if (builder.length() != 0) builder.append(':');
|
||||
builder.append(part);
|
||||
builder.append(part == null ? "<unknown>" : part);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+31
-31
@@ -77,13 +77,13 @@ public class Maven2ServerIndexerImpl extends MavenRemoteObject implements MavenS
|
||||
@Nullable String url,
|
||||
@NotNull File indexDir) throws MavenServerIndexerException {
|
||||
try {
|
||||
IndexingContext context = myIndexer.addIndexingContext(indexId,
|
||||
repositoryId,
|
||||
file,
|
||||
indexDir,
|
||||
url,
|
||||
null, // repo update url
|
||||
NexusIndexer.FULL_INDEX);
|
||||
IndexingContext context = myIndexer.addIndexingContextForced(indexId,
|
||||
repositoryId,
|
||||
file,
|
||||
indexDir,
|
||||
url,
|
||||
null, // repo update url
|
||||
NexusIndexer.FULL_INDEX);
|
||||
int id = System.identityHashCode(context);
|
||||
myIndices.put(id, context);
|
||||
return id;
|
||||
@@ -143,31 +143,31 @@ public class Maven2ServerIndexerImpl extends MavenRemoteObject implements MavenS
|
||||
Maven2ServerEmbedderImpl embedder = Maven2ServerEmbedderImpl.create(settings);
|
||||
try {
|
||||
request.setResourceFetcher(new Maven2ServerIndexFetcher(index.getRepositoryId(),
|
||||
index.getRepositoryUrl(),
|
||||
embedder.getComponent(WagonManager.class),
|
||||
new TransferListenerAdapter(indicator) {
|
||||
@Override
|
||||
protected void downloadProgress(long downloaded, long total) {
|
||||
super.downloadProgress(downloaded, total);
|
||||
try {
|
||||
myIndicator.setFraction(((double)downloaded) / total);
|
||||
}
|
||||
catch (RemoteException e) {
|
||||
throw new RuntimeRemoteException(e);
|
||||
}
|
||||
}
|
||||
index.getRepositoryUrl(),
|
||||
embedder.getComponent(WagonManager.class),
|
||||
new TransferListenerAdapter(indicator) {
|
||||
@Override
|
||||
protected void downloadProgress(long downloaded, long total) {
|
||||
super.downloadProgress(downloaded, total);
|
||||
try {
|
||||
myIndicator.setFraction(((double)downloaded) / total);
|
||||
}
|
||||
catch (RemoteException e) {
|
||||
throw new RuntimeRemoteException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transferCompleted(TransferEvent event) {
|
||||
super.transferCompleted(event);
|
||||
try {
|
||||
myIndicator.setText2("Processing indices...");
|
||||
}
|
||||
catch (RemoteException e) {
|
||||
throw new RuntimeRemoteException(e);
|
||||
}
|
||||
}
|
||||
}));
|
||||
@Override
|
||||
public void transferCompleted(TransferEvent event) {
|
||||
super.transferCompleted(event);
|
||||
try {
|
||||
myIndicator.setText2("Processing indices...");
|
||||
}
|
||||
catch (RemoteException e) {
|
||||
throw new RuntimeRemoteException(e);
|
||||
}
|
||||
}
|
||||
}));
|
||||
myUpdater.fetchAndUpdateIndex(request);
|
||||
}
|
||||
finally {
|
||||
|
||||
@@ -162,7 +162,7 @@ public class MavenIndex {
|
||||
catch (Exception e2) {
|
||||
throw new MavenIndexException("Cannot open index " + myDir.getPath(), e2);
|
||||
}
|
||||
isBroken = true;
|
||||
markAsBroken();
|
||||
}
|
||||
}
|
||||
finally {
|
||||
@@ -581,12 +581,17 @@ public class MavenIndex {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
isBroken = true;
|
||||
myListener.indexIsBroken(this);
|
||||
markAsBroken();
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
private void markAsBroken() {
|
||||
if (!isBroken) {
|
||||
myListener.indexIsBroken(this);
|
||||
}
|
||||
isBroken = true;
|
||||
}
|
||||
|
||||
private interface IndexTask<T> {
|
||||
T doTask() throws Exception;
|
||||
}
|
||||
|
||||
@@ -274,6 +274,14 @@ public class MavenIndicesTest extends MavenIndicesTestCase {
|
||||
myIndices.updateOrRepair(i, true, getMavenGeneralSettings(), EMPTY_MAVEN_PROCESS);
|
||||
}
|
||||
|
||||
public void testFoo() throws Exception {
|
||||
myIndices.add("id", myRepositoryHelper.getTestDataPath("local1"), MavenIndex.Kind.LOCAL);
|
||||
shutdownIndices();
|
||||
initIndices();
|
||||
|
||||
assertFalse(isBroken);
|
||||
}
|
||||
|
||||
public void testSavingFailureMessage() throws Exception {
|
||||
MavenIndex i = myIndices.add("id", "xxx", MavenIndex.Kind.REMOTE);
|
||||
myIndices.updateOrRepair(i, true, getMavenGeneralSettings(), EMPTY_MAVEN_PROCESS);
|
||||
|
||||
Reference in New Issue
Block a user