sashapolo commented on code in PR #2823:
URL: https://github.com/apache/ignite-3/pull/2823#discussion_r1387811566


##########
modules/rest/src/main/java/org/apache/ignite/internal/rest/RestComponent.java:
##########
@@ -115,9 +122,12 @@ public void start() {
      * @return {@code True} if server was started successfully, {@code False} 
if couldn't bind one of the ports.
      */
     private synchronized boolean startServer(int httpPortCandidate, int 
httpsPortCandidate, boolean sslEnabled, boolean dualProtocol) {
+        // Workaround to avoid micronaut race condition on startup.
+        SHARED_STARTUP_LOCK.lock();
         try {
             httpPort = httpPortCandidate;

Review Comment:
   Not related to this PR, but both `httpPort` and `httpsPort` must be made 
`volatile`, there's a race condition in `httpPort()` and `httpsPort()`  methods



##########
modules/rest/src/main/java/org/apache/ignite/internal/rest/RestComponent.java:
##########
@@ -51,6 +53,11 @@
  * resources for the example.
  */
 public class RestComponent implements IgniteComponent {
+    /**
+     * Lock for micronaut server startup.
+     * TODO: remove when fix 
https://github.com/micronaut-projects/micronaut-core/issues/10091
+     */
+    private static final Lock SHARED_STARTUP_LOCK = new ReentrantLock();

Review Comment:
   Just curious: why do you use a `Lock` and not `synchronized` on a static 
Object?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to