void internalClose() { close(() -> new CentralDogmaException("should never reach here")); }
@Override public synchronized Throwable fillInStackTrace() { filledInStackTrace.set(true); return super.fillInStackTrace(); } };
@Test public void tracelessInstantiation() { final AtomicBoolean filledInStackTrace = new AtomicBoolean(); final CentralDogmaException e = new CentralDogmaException("foo", false) { private static final long serialVersionUID = -4128575947135273677L; @Override public synchronized Throwable fillInStackTrace() { filledInStackTrace.set(true); return super.fillInStackTrace(); } }; assertThat(e).hasMessage("foo"); assertThat(e.getStackTrace()).isEmpty(); assertThat(filledInStackTrace).isFalse(); } }
void internalClose() { close(() -> new CentralDogmaException("should never reach here")); }
void internalClose() { close(() -> new CentralDogmaException("should never reach here")); }
private void loadChildren() { boolean success = false; try { final File[] childFiles = rootDir.listFiles(); if (childFiles != null) { for (File f : childFiles) { loadChild(f); } } success = true; } finally { if (!success) { close(() -> new CentralDogmaException("should never reach here")); } } }
private void loadChildren() { boolean success = false; try { final File[] childFiles = rootDir.listFiles(); if (childFiles != null) { for (File f : childFiles) { loadChild(f); } } success = true; } finally { if (!success) { close(() -> new CentralDogmaException("should never reach here")); } } }
private void loadChildren() { boolean success = false; try { final File[] childFiles = rootDir.listFiles(); if (childFiles != null) { for (File f : childFiles) { loadChild(f); } } success = true; } finally { if (!success) { close(() -> new CentralDogmaException("should never reach here")); } } }
/** * Opens an existing project. */ DefaultProject(File rootDir, Executor repositoryWorker, @Nullable RepositoryCache cache) { requireNonNull(rootDir, "rootDir"); requireNonNull(repositoryWorker, "repositoryWorker"); if (!rootDir.exists()) { throw new ProjectNotFoundException(rootDir.toString()); } name = rootDir.getName(); repos = newRepoManager(rootDir, repositoryWorker, cache); boolean success = false; try { createReservedRepos(System.currentTimeMillis()); success = true; } finally { if (!success) { repos.close(() -> new CentralDogmaException("failed to initialize internal repositories")); } } }
/** * Opens an existing project. */ DefaultProject(File rootDir, Executor repositoryWorker, @Nullable RepositoryCache cache) { requireNonNull(rootDir, "rootDir"); requireNonNull(repositoryWorker, "repositoryWorker"); if (!rootDir.exists()) { throw new ProjectNotFoundException(rootDir.toString()); } name = rootDir.getName(); repos = newRepoManager(rootDir, repositoryWorker, cache); boolean success = false; try { createReservedRepos(System.currentTimeMillis()); success = true; } finally { if (!success) { repos.close(() -> new CentralDogmaException("failed to initialize internal repositories")); } } }
/** * Opens an existing project. */ DefaultProject(File rootDir, Executor repositoryWorker, @Nullable RepositoryCache cache) { requireNonNull(rootDir, "rootDir"); requireNonNull(repositoryWorker, "repositoryWorker"); if (!rootDir.exists()) { throw new ProjectNotFoundException(rootDir.toString()); } name = rootDir.getName(); repos = newRepoManager(rootDir, repositoryWorker, cache); boolean success = false; try { createReservedRepos(System.currentTimeMillis()); success = true; } finally { if (!success) { repos.close(() -> new CentralDogmaException("failed to initialize internal repositories")); } } }
/** * Creates a new project. */ DefaultProject(File rootDir, Executor repositoryWorker, @Nullable RepositoryCache cache, long creationTimeMillis, Author author) { requireNonNull(rootDir, "rootDir"); requireNonNull(repositoryWorker, "repositoryWorker"); if (rootDir.exists()) { throw new ProjectExistsException(rootDir.getName()); } name = rootDir.getName(); repos = newRepoManager(rootDir, repositoryWorker, cache); boolean success = false; try { createReservedRepos(creationTimeMillis); initializeMetadata(creationTimeMillis, author); success = true; } finally { if (!success) { repos.close(() -> new CentralDogmaException("failed to initialize internal repositories")); } } }
/** * Creates a new project. */ DefaultProject(File rootDir, Executor repositoryWorker, @Nullable RepositoryCache cache, long creationTimeMillis, Author author) { requireNonNull(rootDir, "rootDir"); requireNonNull(repositoryWorker, "repositoryWorker"); if (rootDir.exists()) { throw new ProjectExistsException(rootDir.getName()); } name = rootDir.getName(); repos = newRepoManager(rootDir, repositoryWorker, cache); boolean success = false; try { createReservedRepos(creationTimeMillis); initializeMetadata(creationTimeMillis, author); success = true; } finally { if (!success) { repos.close(() -> new CentralDogmaException("failed to initialize internal repositories")); } } }
/** * Creates a new project. */ DefaultProject(File rootDir, Executor repositoryWorker, @Nullable RepositoryCache cache, long creationTimeMillis, Author author) { requireNonNull(rootDir, "rootDir"); requireNonNull(repositoryWorker, "repositoryWorker"); if (rootDir.exists()) { throw new ProjectExistsException(rootDir.getName()); } name = rootDir.getName(); repos = newRepoManager(rootDir, repositoryWorker, cache); boolean success = false; try { createReservedRepos(creationTimeMillis); initializeMetadata(creationTimeMillis, author); success = true; } finally { if (!success) { repos.close(() -> new CentralDogmaException("failed to initialize internal repositories")); } } }
.getErrorCode()) { case UNIMPLEMENTED: convertedCause = new CentralDogmaException("unimplemented", false); break; case INTERNAL_SERVER_ERROR: convertedCause = new CentralDogmaException("internal server error", false); break; case BAD_REQUEST: convertedCause = new CentralDogmaException("bad request", false); break; case PROJECT_NOT_FOUND:
.getErrorCode()) { case UNIMPLEMENTED: convertedCause = new CentralDogmaException("unimplemented", false); break; case INTERNAL_SERVER_ERROR: convertedCause = new CentralDogmaException("internal server error", false); break; case BAD_REQUEST: convertedCause = new CentralDogmaException("bad request", false); break; case PROJECT_NOT_FOUND:
.getErrorCode()) { case UNIMPLEMENTED: convertedCause = new CentralDogmaException("unimplemented", false); break; case INTERNAL_SERVER_ERROR: convertedCause = new CentralDogmaException("internal server error", false); break; case BAD_REQUEST: convertedCause = new CentralDogmaException("bad request", false); break; case PROJECT_NOT_FOUND:
@Test public void operationOnClosedRepository() throws Exception { final CentralDogmaException expectedException = new CentralDogmaException(); final GitRepository repo = new GitRepository(mock(Project.class), new File(repoDir.getRoot(), "close_test_repo"), commonPool(), 0L, Author.SYSTEM); repo.close(() -> expectedException); assertThatThrownBy(() -> repo.find(INIT, "/**").join()).hasCause(expectedException); assertThatThrownBy(() -> repo.history(INIT, HEAD, "/**").join()).hasCause(expectedException); assertThatThrownBy(() -> repo.diff(INIT, HEAD, "/**").join()).hasCause(expectedException); assertThatThrownBy(() -> repo.previewDiff( INIT, Change.ofTextUpsert("/foo.txt", "foo")).join()).hasCause(expectedException); assertThatThrownBy(() -> repo.commit( INIT, 0, Author.SYSTEM, "foo", Change.ofTextUpsert("/foo", "foo")).join()).hasCause(expectedException); assertThatThrownBy(() -> repo.watch( INIT, "/**").get(10, TimeUnit.SECONDS)).hasCause(expectedException); assertThatThrownBy(() -> repo.watch( INIT, Query.ofJson("/foo.json")).get(10, TimeUnit.SECONDS)).hasCause(expectedException); } }