Skip to content

Commit

Permalink
Fix deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
slonopotamus committed Jul 13, 2018
1 parent d89e297 commit 648dd6b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
Expand Up @@ -162,7 +162,7 @@ private String getPathInfo(@NotNull HttpRequest req) throws URISyntaxException {
@NotNull
private Map<String, String[]> getParameterMap(@NotNull HttpRequest req) throws URISyntaxException {
final Map<String, List<String>> params = new HashMap<>();
final List<NameValuePair> pairList = URLEncodedUtils.parse(new URI(req.getRequestLine().getUri()), StandardCharsets.UTF_8.name());
final List<NameValuePair> pairList = URLEncodedUtils.parse(new URI(req.getRequestLine().getUri()), StandardCharsets.UTF_8);
for (NameValuePair param : pairList) {
params.compute(param.getName(), (item, value) -> {
if (value == null) {
Expand Down
20 changes: 8 additions & 12 deletions src/main/java/svnserver/repository/git/GitRepository.java
Expand Up @@ -125,9 +125,10 @@ public GitRepository(@NotNull LocalContext context,
this.lockManagerFactory = lockManagerFactory;
this.gitFilters = GitFilterHelper.createFilters(context);

this.svnBranch = LayoutHelper.initRepository(repository, branch).getName();
final Ref svnBranchRef = LayoutHelper.initRepository(repository, branch);
this.svnBranch = svnBranchRef.getName();
this.gitBranch = Constants.R_HEADS + branch;
final String repositoryId = loadRepositoryId(repository, svnBranch);
final String repositoryId = loadRepositoryId(repository, svnBranchRef);
this.uuid = UUID.nameUUIDFromBytes((repositoryId + "\0" + gitBranch).getBytes(StandardCharsets.UTF_8)).toString();

log.info("[{}]: registered branch: {}", context.getName(), gitBranch);
Expand All @@ -145,12 +146,7 @@ public void close() {
}

@NotNull
private static String loadRepositoryId(@NotNull Repository repository, @NotNull String refName) throws IOException {
final Ref ref = repository.getRef(refName);
if (ref == null) {
throw new IllegalStateException();
}

private static String loadRepositoryId(@NotNull Repository repository, @NotNull Ref ref) throws IOException {
ObjectId oid = ref.getObjectId();
final RevWalk revWalk = new RevWalk(repository);
while (true) {
Expand All @@ -176,7 +172,7 @@ private void loadRevisions() throws IOException, SVNException {
final ObjectId lastCommitId;
if (lastRevision >= 0) {
lastCommitId = revisions.get(lastRevision).getCacheCommit();
final Ref head = repository.getRef(svnBranch);
final Ref head = repository.exactRef(svnBranch);
if (head.getObjectId().equals(lastCommitId)) {
return;
}
Expand All @@ -189,7 +185,7 @@ private void loadRevisions() throws IOException, SVNException {
try {
final int lastRevision = revisions.size() - 1;
final ObjectId lastCommitId = lastRevision < 0 ? null : revisions.get(lastRevision).getCacheCommit();
final Ref head = repository.getRef(svnBranch);
final Ref head = repository.exactRef(svnBranch);
final List<RevCommit> newRevs = new ArrayList<>();
final RevWalk revWalk = new RevWalk(repository);
ObjectId objectId = head.getObjectId();
Expand Down Expand Up @@ -256,7 +252,7 @@ public boolean cacheRevisions() throws IOException {
final int lastRevision = revisions.size() - 1;
if (lastRevision >= 0) {
final ObjectId lastCommitId = revisions.get(lastRevision).getGitNewCommit();
final Ref master = repository.getRef(gitBranch);
final Ref master = repository.exactRef(gitBranch);
if ((master == null) || (master.getObjectId().equals(lastCommitId))) {
return false;
}
Expand All @@ -268,7 +264,7 @@ public boolean cacheRevisions() throws IOException {
final ObjectInserter inserter = repository.newObjectInserter();
lock.writeLock().lock();
try {
final Ref master = repository.getRef(gitBranch);
final Ref master = repository.exactRef(gitBranch);
final List<RevCommit> newRevs = new ArrayList<>();
final RevWalk revWalk = new RevWalk(repository);
ObjectId objectId = master.getObjectId();
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/svnserver/repository/git/LayoutHelper.java
Expand Up @@ -53,9 +53,9 @@ public final class LayoutHelper {

@NotNull
public static Ref initRepository(@NotNull Repository repository, String branch) throws IOException {
Ref ref = repository.getRef(PREFIX_REF + branch);
Ref ref = repository.exactRef(PREFIX_REF + branch);
if (ref == null) {
Ref old = repository.getRef(OLD_CACHE_REF);
Ref old = repository.exactRef(OLD_CACHE_REF);
if (old != null) {
final RefUpdate refUpdate = repository.updateRef(PREFIX_REF + branch);
refUpdate.setNewObjectId(old.getObjectId());
Expand All @@ -67,12 +67,12 @@ public static Ref initRepository(@NotNull Repository repository, String branch)
final RefUpdate refUpdate = repository.updateRef(PREFIX_REF + branch);
refUpdate.setNewObjectId(revision);
refUpdate.update();
ref = repository.getRef(PREFIX_REF + branch);
ref = repository.exactRef(PREFIX_REF + branch);
if (ref == null) {
throw new IOException("Can't initialize repository.");
}
}
Ref old = repository.getRef(OLD_CACHE_REF);
Ref old = repository.exactRef(OLD_CACHE_REF);
if (old != null) {
final RefUpdate refUpdate = repository.updateRef(OLD_CACHE_REF);
refUpdate.setForceUpdate(true);
Expand Down

0 comments on commit 648dd6b

Please sign in to comment.