Conversation
| } | ||
| dependencies { | ||
| classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.2' | ||
| classpath 'com.google.guava:guava:23.5-jre' |
There was a problem hiding this comment.
С отступами что-то не так :) Где-то пробелы, где-то табы
| } | ||
| // configurationParameter 'junit.jupiter.conditions.deactivate', '*' | ||
| // enableStandardTestTask true | ||
| // reportsDir file('build/test-results/junit-platform') // this is the default |
There was a problem hiding this comment.
Куча закомментированного кода, в общем-то, не нужна. Это же какой-то стандартный пример, можно было его почистить
| import java.util.function.Supplier; | ||
|
|
||
| /** | ||
| * Factory class to produce different ru.spbau.mit.kirakosian.Lazy classes. Unsynchronized and synchronized versions |
There was a problem hiding this comment.
ru.spbau.mit.kirakosian.Lazy в комментарии --- неудачное переименование? :)
| } | ||
|
|
||
| // as i see, if there is no description the one from the interface will be shown | ||
| // it looks more beautiful then the link in my opinion |
| synchronized (this) { | ||
| if (supplier != null) { // check that we have not done this section yet | ||
| value = supplier.get(); | ||
| supplier = null; |
There was a problem hiding this comment.
supplier надо сделать volatile, иначе получится как описано тут: https://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html. supplier уже null, поэтому условие в строке 85 уже ложно, но в value ещё фигня какая-то.
| oneCreateSynchronizedLazyTest("hello"); | ||
| oneCreateSynchronizedLazyTest(null); | ||
| } catch (@NotNull final InterruptedException e) { | ||
| // no idea what to do here... It is not a failure |
There was a problem hiding this comment.
Дать ему упасть. InterruptedException-ов ведь в этом тестовом сценарии быть не должно. Так что лучше прописать InterruptedException в throws, и если поток таки кто-то прервёт, пусть тест не пройдёт.
yurii-litvinov
left a comment
There was a problem hiding this comment.
Окей, теперь существенных замечаний не осталось, зачтена.
| } | ||
| dependencies { | ||
| classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.2' | ||
| classpath 'com.google.guava:guava:23.5-jre' |
| * | ||
| * @param supplier supplier to get element from. | ||
| * @param <T> type of the stored in ru.spbau.mit.kirakosian.Lazy element | ||
| * @return new concurrent unsafe ru.spbau.mit.kirakosian.Lazy instance |
There was a problem hiding this comment.
Ну и я бы сказал, что последствия неудачных переименований надо ликвидировать. Либо если это было сделано намеренно, то всё равно ликвидировать :)
No description provided.