-
Notifications
You must be signed in to change notification settings - Fork 350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The static method java.lang.ThreadLocal.withInitial is added On line 99 #301
Conversation
Thank you for your contribution. Is there a unit test available that fails without the new method, so we can confirm that it works as intended? If there is no existing test, could you please try to create one? |
@cyrille-artho Can you please help me with the unit test because I'm not familiar with it |
The key challenge is to find a small program that fails without your patch but which works with it. (Possibly this could mean that under a certain version of the JDK, the code may not compile without the patch.) |
Hi @cyrille-artho Can you please tell me how to find an example? |
Hi Guarang,
I assume that this either won't compile without your patch (as constructor with the "supplier" lambda expression argument is not available without it) or will not return the correct value. |
Hi @cyrille-artho, I have written some example code to for unit test please look at it ` import javax.sound.sampled.SourceDataLine; public class ThreadLocalInitialValueExample {
}` |
Hi, |
Hi @cyrille-artho , |
@cyrille-artho |
Hi @cyrille-artho |
Could you please complete the unit test so it has an assertion that checks the behavior? The output is not easy to inspect when run on Gradle's test runner. The test code was also not 100 % complete so it does not compile without the additional imports for JUnit. |
Hi @cyrille-artho, |
As a first step, simply add one of your examples to the pull request (as a program that runs from |
Hi @cyrille-artho, |
Hi @cyrille-artho |
Hi, |
@cyrille-artho |
Hi @cyrille-artho, |
Hi @cyrille-artho |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Guarang,
Great job! This version works perfectly. I'd just like you to make two small cosmetic changes before merging.
@@ -21,6 +21,8 @@ | |||
import java.lang.ref.WeakReference; | |||
import java.util.Objects; | |||
import java.util.function.Supplier; | |||
import java.sql.Date; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove these two unused imports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes are done
src/tests/ThreadLocalTest/App.java
Outdated
final SimpleDateFormat df = threadSafeFormatter.df.get(); | ||
return df.format(birthdDate); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a newline character (line break) at the end of the last line.
Hi @cyrille-artho Changes are done |
Hi, |
okay so now I only need to add a new line character like |
@cyrille-artho I've removed print statment can you please tell me what should I do next? |
Hi @cyrille-artho,
|
Looks good. Thank you very much for your effort and patience. |
@cyrille-artho Thank you for guiding me for my First contribution really excited to do more |
You're welcome. There are many open issues on the issue tracker left, and other features that are not yet tested (or documented as issues), for example, the |
Hi @cyrille-artho, |
I have not documented anything yet (and doing so on the issue tracker would be a good start). https://docs.oracle.com/javase/8/docs/api/java/util/stream/package-summary.html Simply including a few examples would be helpful to see if JPF can handle these cases at all (there may be missing native peer classes/methods), and what problems there might be. I have created a new issue for this: #302 |
Co-authored-by: varad64 <[email protected]>
Added method
public static
ThreadLocalwithInitial(Supplier<? extends S> supplier) {return new SuppliedThreadLocal<>(supplier);
}