Skip to content

Conversation

@asurkov
Copy link
Contributor

@asurkov asurkov commented Oct 21, 2017

No description provided.

@asurkov asurkov requested a review from astansler October 21, 2017 05:10
val repo: Repository = git.repository
val head: RevCommit =
RevWalk(repo).parseCommit(repo.resolve(RepoHelper.MASTER_BRANCH))
try { RevWalk(repo).parseCommit(repo.resolve("HEAD")) }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All hashers should be consistent in what branch they hash. We have agreement of hashing master branch, ref defined in RepoHelper.MASTER_BRANCH.

val head: RevCommit =
RevWalk(repo).parseCommit(repo.resolve(RepoHelper.MASTER_BRANCH))
try { RevWalk(repo).parseCommit(repo.resolve("HEAD")) }
catch(e: Exception) { throw Exception("No default branch") }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No master branch. But existence of master branch checked before run of hasher, so this check is excess.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

np, I'll revert the branch name change. However I think this requirement is too restrictive though and overcomplicates the things in general. I'll file a bug on it to have further discussion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw, I'd like to keep the try/catch thing if that was your point, because it's useful for testing outside the main infrastructure.

if (Files.notExists(Paths.get(storageDir))) {
Files.createDirectories(Paths.get(storageDir))
}
val oStream = ObjectOutputStream(FileOutputStream(storagePath))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This call should be encapsulated with try-catch, cuz can produce exceptions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same, what do you want to see under a catch block?

}

val ageData = (iStream?.readObject() ?: CodeLineAges()) as CodeLineAges
catch(e: FileNotFoundException) { }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ObjectInputStream and FileInputStream can possibly produce a lot of different exceptions, so e: Exception is more appropriate as it generic. We should fail hashing in case of problems with loading of data for incremental updates.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This done on purpose, if something bad or unexpected happens I want to know that. This bug was also found, because we don't hide exceptions. We may want to hide that on release builds, but that's definitely useful thing for testing and debugging.

try {
val iStream = ObjectInputStream(FileInputStream(storagePath))
val storedHeadId = iStream.readUTF()
Logger.debug("Stored repo head: storedHeadId")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed $ for substitution.

return null
try {
val iStream = ObjectInputStream(FileInputStream(storagePath))
val storedHeadId = iStream.readUTF()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add comment that this method read first line of file? Really strange naming of method they've made.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure whether it read the first line or not, it reads a string whatever format it has. I can add a comment like "Storage format: commit id and CodeLineAges structure following it" if you think it makes sense.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, nice.

Copy link
Member

@astansler astansler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@asurkov asurkov merged commit d2d69d9 into develop Oct 24, 2017
@asurkov asurkov deleted the so_crash branch October 24, 2017 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants