anon-iclr-submission/benchname-bug-localization huggingface dataset:
Repository: quarkusio/quarkus
Issue: quarkus-maven-plugin runs native building even if the profile is commented out

### Describe the bug

It comes across 
- https://github.com/apache/camel-quarkus/issues/5180

The `native` profile is commented out but quarkus build is still running the graal native build. After investigating, it seems related to https://github.com/quarkusio/quarkus/blob/3747c0d85b68ca33b58871d9cf3b2d4b3bb304a4/devtools/maven/src/main/java/io/quarkus/maven/BuildMojo.java#L121-L123

I think it should check `setPackageTypeSystemPropertyIfNativeProfileEnabled` is **true**. 

### Expected behavior

No running the native build.

### Actual behavior

The native build is still running.

### How to Reproduce?

_No response_

### Output of `uname -a` or `ver`

_No response_

### Output of `java -version`

_No response_

### GraalVM version (if different from Java)

_No response_

### Quarkus version or git rev

3.2.4.Final

### Build tool (ie. output of `mvnw --version` or `gradlew --version`)

_No response_

### Additional information

_No response_

Changed files:
devtools/maven/src/main/java/io/quarkus/maven/BuildMojo.java, devtools/maven/src/main/java/io/quarkus/maven/TrackConfigChangesMojo.java

diff --git a/devtools/maven/src/main/java/io/quarkus/maven/BuildMojo.java b/devtools/maven/src/main/java/io/quarkus/maven/BuildMojo.java
index 0c7146ddb16..fefb7457970 100644
--- a/devtools/maven/src/main/java/io/quarkus/maven/BuildMojo.java
+++ b/devtools/maven/src/main/java/io/quarkus/maven/BuildMojo.java
@@ -118,7 +118,7 @@ protected void doExecute() throws MojoExecutionException {
             // Essentially what this does is to enable the native package type even if a different package type is set
             // in application properties. This is done to preserve what users expect to happen when
             // they execute "mvn package -Dnative" even if quarkus.package.type has been set in application.properties
-            if (!setPackageTypeSystemPropertyIfNativeProfileEnabled()) {
+            if (setPackageTypeSystemPropertyIfNativeProfileEnabled()) {
                 propertiesToClear.add(PACKAGE_TYPE_PROP);
             }
 
diff --git a/devtools/maven/src/main/java/io/quarkus/maven/TrackConfigChangesMojo.java b/devtools/maven/src/main/java/io/quarkus/maven/TrackConfigChangesMojo.java
index e721cf89e80..b8b43e94db0 100644
--- a/devtools/maven/src/main/java/io/quarkus/maven/TrackConfigChangesMojo.java
+++ b/devtools/maven/src/main/java/io/quarkus/maven/TrackConfigChangesMojo.java
@@ -132,7 +132,9 @@ protected void doExecute() throws MojoExecutionException, MojoFailureException {
         } catch (Exception any) {
             throw new MojoExecutionException("Failed to bootstrap Quarkus application", any);
         } finally {
-            System.clearProperty(PACKAGE_TYPE_PROP);
+            if (clearPackageTypeSystemProperty) {
+                System.clearProperty(PACKAGE_TYPE_PROP);
+            }
             Thread.currentThread().setContextClassLoader(originalCl);
             if (deploymentClassLoader != null) {
                 deploymentClassLoader.close();
Repository: quarkusio/quarkus
Issue: quarkus.analytics.uri.base unrecognized by build time analytics

### Describe the bug

`quarkus-maven-plugin` reports a warning
```
[WARNING] [io.quarkus.config] Unrecognized configuration key "quarkus.analytics.uri.base" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
```
when the `quarkus.analytics.uri.base` is provided.

The warning is issued regardless of whether the analytics are active or not.

The other analytics-related properties are fine:
```
quarkus.analytics.disabled
quarkus.analytics.timeout
```

### Expected behavior

No warning in build/app log.

### Actual behavior

_No response_

### How to Reproduce?

```
quarkus create app bta-reproducer --no-code
cd bta-reproducer
quarkus build -Dquarkus.analytics.uri.base="http://fake.url"
```

### Output of `uname -a` or `ver`

Linux 6.2.15-200.fc37.x86_64

### Output of `java -version`

openjdk 17.0.7 2023-04-18

### GraalVM version (if different from Java)

_No response_

### Quarkus version or git rev

3.2.0.Final, 999-SNAPSHOT

### Build tool (ie. output of `mvnw --version` or `gradlew --version`)

3.8.8

### Additional information

_No response_

Changed files:
core/runtime/src/main/java/io/quarkus/runtime/BuildAnalyticsConfig.java

diff --git a/core/runtime/src/main/java/io/quarkus/runtime/BuildAnalyticsConfig.java b/core/runtime/src/main/java/io/quarkus/runtime/BuildAnalyticsConfig.java
index e34b1a0e1af..73929157752 100644
--- a/core/runtime/src/main/java/io/quarkus/runtime/BuildAnalyticsConfig.java
+++ b/core/runtime/src/main/java/io/quarkus/runtime/BuildAnalyticsConfig.java
@@ -23,7 +23,7 @@ public class BuildAnalyticsConfig {
     /**
      * The Segment base URI.
      */
-    @ConfigItem
+    @ConfigItem(name = "uri.base")
     public Optional<String> uriBase;
 
     /**
Repository: codecentric/spring-boot-admin
Issue: Unable to override spring.security.user.name and spring.security.user.password credentials in spring-boot-admin-sample-servlet sample

I was unable to override `spring.security.user.name` and `spring.security.user.password` credentials in spring-boot-admin-sample-servlet sample when I migrate from 2.1.6 to 2.3.1.

I think the problem may be related to this code [here](https://github.com/codecentric/spring-boot-admin/blob/10022c67a0fcbd6d6dadaf969a423824cc68ce5b/spring-boot-admin-samples/spring-boot-admin-sample-servlet/src/main/java/de/codecentric/boot/admin/SecuritySecureConfig.java#L71). It forces fixed credentials.

I look forward to your answer.

Changed files:
spring-boot-admin-samples/spring-boot-admin-sample-servlet/src/main/java/de/codecentric/boot/admin/SecuritySecureConfig.java

diff --git a/spring-boot-admin-samples/spring-boot-admin-sample-servlet/src/main/java/de/codecentric/boot/admin/SecuritySecureConfig.java b/spring-boot-admin-samples/spring-boot-admin-sample-servlet/src/main/java/de/codecentric/boot/admin/SecuritySecureConfig.java
index 314539e7..794cc43c 100644
--- a/spring-boot-admin-samples/spring-boot-admin-sample-servlet/src/main/java/de/codecentric/boot/admin/SecuritySecureConfig.java
+++ b/spring-boot-admin-samples/spring-boot-admin-sample-servlet/src/main/java/de/codecentric/boot/admin/SecuritySecureConfig.java
@@ -18,6 +18,7 @@ package de.codecentric.boot.admin;
 
 import java.util.UUID;
 
+import org.springframework.boot.autoconfigure.security.SecurityProperties;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Profile;
 import org.springframework.http.HttpMethod;
@@ -38,8 +39,11 @@ public class SecuritySecureConfig extends WebSecurityConfigurerAdapter {
 
 	private final AdminServerProperties adminServer;
 
-	public SecuritySecureConfig(AdminServerProperties adminServer) {
+	private final SecurityProperties security;
+
+	public SecuritySecureConfig(AdminServerProperties adminServer, SecurityProperties security) {
 		this.adminServer = adminServer;
+		this.security = security;
 	}
 
 	@Override
@@ -70,7 +74,8 @@ public class SecuritySecureConfig extends WebSecurityConfigurerAdapter {
 	// Required to provide UserDetailsService for "remember functionality"
 	@Override
 	protected void configure(AuthenticationManagerBuilder auth) throws Exception {
-		auth.inMemoryAuthentication().withUser("user").password("{noop}password").roles("USER");
+		auth.inMemoryAuthentication().withUser(security.getUser().getName())
+				.password("{noop}" + security.getUser().getPassword()).roles("USER");
 	}
 
 }
Repository: zaproxy/zaproxy
Issue: Can not scroll past 'contexts' in 'sites' tab with FlatLaf L&F

**Describe the bug**
Can not use mouse wheel to scroll past 'Context' in 'Sites' tab.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to 'Sites'
2. Browse around a bunch with the proxy on so the Sites populate
3. Scroll to the top of the list with both sites and contexts expanded
4. Use mouse wheel to scroll down

**Expected behavior**
The list scrolls normally to the bottom.

**Observed behavior**
The scrolling stops at the end of Contexts. Neither can you use arrow keys to go down from the bottom most entry in contexts.
However dragging the scrollbar manually with the mouse past that point allows normal scrolling. Just not when any context is in view.

**Screenshots**
N/A

**Software versions**
 - ZAP: 2.10
 - Add-on: N/A
 - OS: Ubuntu 20.04 (5.4.0-70-generic, amd64)
 - Java: openjdk 11.0.10 2021-01-19
 - Browser: N/A

**Errors from the zap.log file**
None

**Additional context**
None

**Would you like to help fix this issue?**
I don't do java.

Changed files:
zap/src/main/java/org/zaproxy/zap/view/ContextsSitesPanel.java

diff --git a/zap/src/main/java/org/zaproxy/zap/view/ContextsSitesPanel.java b/zap/src/main/java/org/zaproxy/zap/view/ContextsSitesPanel.java
index 228d29780..3d901a09f 100644
--- a/zap/src/main/java/org/zaproxy/zap/view/ContextsSitesPanel.java
+++ b/zap/src/main/java/org/zaproxy/zap/view/ContextsSitesPanel.java
@@ -110,7 +110,12 @@ public class ContextsSitesPanel extends JPanel {
         public int getScrollableUnitIncrement(
                 Rectangle visibleRect, int orientation, int direction) {
             if (visibleRect.getY() < sitesTree.getBounds().getY()) {
-                return contextsTree.getScrollableUnitIncrement(visibleRect, orientation, direction);
+                int unitIncrement =
+                        contextsTree.getScrollableUnitIncrement(
+                                visibleRect, orientation, direction);
+                if (unitIncrement != 0) {
+                    return unitIncrement;
+                }
             }
             return sitesTree.getScrollableUnitIncrement(visibleRect, orientation, direction);
         }
Repository: zaproxy/zaproxy
Issue: Selected checkbox tree nodes not correctly highlighted in macOS

Issue reported in OWASP ZAP User Group: https://groups.google.com/d/msg/zaproxy-users/8xw8VDLbO5U/PbOXDbOaAwAJ

The selected nodes in the checkbox tree are not correctly highlighted (like the Sites tree in #3351).

ZAP version:
Version 2.6.0 (older versions are also affected).

Changed files:
zap/src/main/java/org/zaproxy/zap/view/JCheckBoxTree.java

diff --git a/zap/src/main/java/org/zaproxy/zap/view/JCheckBoxTree.java b/zap/src/main/java/org/zaproxy/zap/view/JCheckBoxTree.java
index 5d5feaebd..fd0134868 100644
--- a/zap/src/main/java/org/zaproxy/zap/view/JCheckBoxTree.java
+++ b/zap/src/main/java/org/zaproxy/zap/view/JCheckBoxTree.java
@@ -167,6 +167,7 @@ public class JCheckBoxTree extends JTree {
             this.setLayout(new BorderLayout());
             checkBox = new JCheckBox();
             altLabel = new JLabel("");
+            altLabel.setOpaque(true);
             add(checkBox, BorderLayout.CENTER);
             add(altLabel, BorderLayout.EAST);
             setOpaque(false);
@@ -188,6 +189,9 @@ public class JCheckBoxTree extends JTree {
             altLabel.setForeground(
                     UIManager.getColor(
                             selected ? "Tree.selectionForeground" : "Tree.textForeground"));
+            altLabel.setBackground(
+                    UIManager.getColor(
+                            selected ? "Tree.selectionBackground" : "Tree.textBackground"));
             CheckedNode cn = nodesCheckingState.get(tp);
             if (cn == null) {
                 checkBox.setVisible(false);
Repository: zaproxy/zaproxy
Issue: Ascan Category summaries not updated

### Describe the bug

The Active scan dialog Category Threshold and Stength columns are not updated when the "Go" buttons are used.
The underlying rules are however set correctly.
https://groups.google.com/g/zaproxy-users/c/AfVXJpiPPYw/m/m4Jg2KmvAQAJ

### Steps to reproduce the behavior

As per https://groups.google.com/g/zaproxy-users/c/AfVXJpiPPYw/m/m4Jg2KmvAQAJ

### Expected behavior

The Threshold and Strength columns should be updated to reflect the new states.

### Software versions

2.12.0

### Screenshots

See https://groups.google.com/g/zaproxy-users/c/AfVXJpiPPYw/m/m4Jg2KmvAQAJ

### Errors from the zap.log file

_No response_

### Additional context

_No response_

### Would you like to help fix this issue?

- [ ] Yes

Changed files:
zap/src/main/java/org/zaproxy/zap/extension/ascan/PolicyAllCategoryPanel.java

diff --git a/zap/src/main/java/org/zaproxy/zap/extension/ascan/PolicyAllCategoryPanel.java b/zap/src/main/java/org/zaproxy/zap/extension/ascan/PolicyAllCategoryPanel.java
index 747d707d0..ab0cfd4b1 100644
--- a/zap/src/main/java/org/zaproxy/zap/extension/ascan/PolicyAllCategoryPanel.java
+++ b/zap/src/main/java/org/zaproxy/zap/extension/ascan/PolicyAllCategoryPanel.java
@@ -279,7 +279,6 @@ public class PolicyAllCategoryPanel extends AbstractParamPanel {
                                 policy = extension.getPolicyManager().getPolicy(policyName);
                                 if (policy != null) {
                                     setScanPolicy(policy);
-                                    fireScanPolicyChanged(policy);
                                 }
                             } catch (ConfigurationException e1) {
                                 LOGGER.error(e1.getMessage(), e1);
@@ -511,11 +510,12 @@ public class PolicyAllCategoryPanel extends AbstractParamPanel {
             throw new InvalidParameterException(
                     "Cannot change policy if the panel has not been defined as switchable");
         }
-        this.policy = scanPolicy;
         this.getPolicySelector().setSelectedItem(scanPolicy.getName());
+        this.policy = scanPolicy;
         this.setThreshold(scanPolicy.getDefaultThreshold());
         this.setStrength(scanPolicy.getDefaultStrength());
         this.getAllCategoryTableModel().setPluginFactory(scanPolicy.getPluginFactory());
+        fireScanPolicyChanged(policy);
     }
 
     @Override
Repository: apache/dolphinscheduler
Issue: [Feature] add user error when user name contains '.'

**Is your feature request related to a problem? Please describe.**
add a user when user name contains '.'

i think maybe the username  regex string is error.


Changed files:
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java

diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java
index 440446e56..791c0bb55 100644
--- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java
+++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java
@@ -315,7 +315,7 @@ public final class Constants {
     /**
      * user name regex
      */
-    public static final Pattern REGEX_USER_NAME = Pattern.compile("^[a-zA-Z0-9_-]{3,20}$");
+    public static final Pattern REGEX_USER_NAME = Pattern.compile("^[a-zA-Z0-9._-]{3,20}$");
 
     /**
      * email regex
Repository: apache/dolphinscheduler
Issue: FetchTaskThread minor bug

should not sleep there.
```
boolean runCheckFlag = OSUtils.checkResource(workerConfig.getWorkerMaxCpuloadAvg(), workerConfig.getWorkerReservedMemory()) && checkThreadCount(poolExecutor);
   
Thread.sleep(Constants.SLEEP_TIME_MILLIS);

                if(!runCheckFlag) {
                    continue;
                }
```
i think the right way is :

```
boolean runCheckFlag = OSUtils.checkResource(workerConfig.getWorkerMaxCpuloadAvg(), workerConfig.getWorkerReservedMemory()) && checkThreadCount(poolExecutor);

                if(!runCheckFlag) {
                    Thread.sleep(Constants.SLEEP_TIME_MILLIS);
                    continue;
                }
```


Changed files:
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/runner/FetchTaskThread.java

diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/runner/FetchTaskThread.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/runner/FetchTaskThread.java
index ae4ee792c..68f27d76d 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/runner/FetchTaskThread.java
+++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/runner/FetchTaskThread.java
@@ -147,9 +147,8 @@ public class FetchTaskThread implements Runnable{
                 //check memory and cpu usage and threads
                 boolean runCheckFlag = OSUtils.checkResource(workerConfig.getWorkerMaxCpuloadAvg(), workerConfig.getWorkerReservedMemory()) && checkThreadCount(poolExecutor);
 
-                Thread.sleep(Constants.SLEEP_TIME_MILLIS);
-
                 if(!runCheckFlag) {
+                    Thread.sleep(Constants.SLEEP_TIME_MILLIS);
                     continue;
                 }
Repository: grpc/grpc-java
Issue: ProtocolNegotiators leaks ByteBufs on failure

As reported by @trask in #1277 with repro repo at https://github.com/trask/grpc-netty-leak-repro. The key distinguishing feature is `BufferUntilChannelActiveHandler` in the log here:

```
SEVERE: LEAK: ByteBuf.release() was not called before it's garbage-collected. See http://netty.io/wiki/reference-counted-objects.html for more information.
Recent access records: 2
#2:
        Hint: 'ProtocolNegotiators$BufferUntilChannelActiveHandler#0' will handle the message from this point.
```

When looking at the code, it is obvious it doesn't release when it fails the promise. This leak only happens when failing to establish a connection to the server.


Changed files:
netty/src/main/java/io/grpc/netty/ProtocolNegotiators.java

diff --git a/netty/src/main/java/io/grpc/netty/ProtocolNegotiators.java b/netty/src/main/java/io/grpc/netty/ProtocolNegotiators.java
index d4b96c946..6414f1dba 100644
--- a/netty/src/main/java/io/grpc/netty/ProtocolNegotiators.java
+++ b/netty/src/main/java/io/grpc/netty/ProtocolNegotiators.java
@@ -60,6 +60,7 @@ import io.netty.handler.ssl.SslContext;
 import io.netty.handler.ssl.SslHandler;
 import io.netty.handler.ssl.SslHandshakeCompletionEvent;
 import io.netty.util.AsciiString;
+import io.netty.util.ReferenceCountUtil;
 
 import java.net.URI;
 import java.util.ArrayDeque;
@@ -388,6 +389,7 @@ public final class ProtocolNegotiators {
        */
       if (failCause != null) {
         promise.setFailure(failCause);
+        ReferenceCountUtil.release(msg);
       } else if (bufferedWrites == null) {
         super.write(ctx, msg, promise);
       } else {
@@ -424,6 +426,7 @@ public final class ProtocolNegotiators {
         while (!bufferedWrites.isEmpty()) {
           ChannelWrite write = bufferedWrites.poll();
           write.promise.setFailure(cause);
+          ReferenceCountUtil.release(write.msg);
         }
         bufferedWrites = null;
       }
Repository: grpc/grpc-java
Issue: ServerCallImpl's use of metadata in sendHeaders is thread-unsafe

`ServerCallImpl` uses metadata to determine compression settings in [sendHeaders](https://github.com/grpc/grpc-java/blob/a2076f4/core/src/main/java/io/grpc/internal/ServerCallImpl.java#L111). However, that `Metadata` has already been passed to the application which is free to modify it. The `acceptEncodings` should just be saved as a field during the constructor instead.


Changed files:
core/src/main/java/io/grpc/internal/ServerCallImpl.java

diff --git a/core/src/main/java/io/grpc/internal/ServerCallImpl.java b/core/src/main/java/io/grpc/internal/ServerCallImpl.java
index 6e0707b32..d2a4e9029 100644
--- a/core/src/main/java/io/grpc/internal/ServerCallImpl.java
+++ b/core/src/main/java/io/grpc/internal/ServerCallImpl.java
@@ -62,7 +62,7 @@ final class ServerCallImpl<ReqT, RespT> extends ServerCall<ReqT, RespT> {
   private final ServerStream stream;
   private final MethodDescriptor<ReqT, RespT> method;
   private final Context.CancellableContext context;
-  private Metadata inboundHeaders;
+  private final String messageAcceptEncoding;
   private final DecompressorRegistry decompressorRegistry;
   private final CompressorRegistry compressorRegistry;
 
@@ -78,7 +78,7 @@ final class ServerCallImpl<ReqT, RespT> extends ServerCall<ReqT, RespT> {
     this.stream = stream;
     this.method = method;
     this.context = context;
-    this.inboundHeaders = inboundHeaders;
+    this.messageAcceptEncoding = inboundHeaders.get(MESSAGE_ACCEPT_ENCODING_KEY);
     this.decompressorRegistry = decompressorRegistry;
     this.compressorRegistry = compressorRegistry;
 
@@ -108,9 +108,9 @@ final class ServerCallImpl<ReqT, RespT> extends ServerCall<ReqT, RespT> {
     if (compressor == null) {
       compressor = Codec.Identity.NONE;
     } else {
-      if (inboundHeaders.containsKey(MESSAGE_ACCEPT_ENCODING_KEY)) {
-        String acceptEncodings = inboundHeaders.get(MESSAGE_ACCEPT_ENCODING_KEY);
-        List<String> acceptedEncodingsList = ACCEPT_ENCODING_SPLITER.splitToList(acceptEncodings);
+      if (messageAcceptEncoding != null) {
+        List<String> acceptedEncodingsList =
+            ACCEPT_ENCODING_SPLITER.splitToList(messageAcceptEncoding);
         if (!acceptedEncodingsList.contains(compressor.getMessageEncoding())) {
           // resort to using no compression.
           compressor = Codec.Identity.NONE;
@@ -119,7 +119,6 @@ final class ServerCallImpl<ReqT, RespT> extends ServerCall<ReqT, RespT> {
         compressor = Codec.Identity.NONE;
       }
     }
-    inboundHeaders = null;
 
     // Always put compressor, even if it's identity.
     headers.put(MESSAGE_ENCODING_KEY, compressor.getMessageEncoding());
@@ -178,7 +177,6 @@ final class ServerCallImpl<ReqT, RespT> extends ServerCall<ReqT, RespT> {
   public void close(Status status, Metadata trailers) {
     checkState(!closeCalled, "call already closed");
     closeCalled = true;
-    inboundHeaders = null;
     stream.close(status, trailers);
   }
Repository: grpc/grpc-java
Issue: Netty Server does not observe channelInactive

If the TCP connection goes down, gRPC isn't noticing because nothing is observing the `channelInactive()` notification on the channel pipeline. I confirmed that `channelInactive()` is called, but saw that an outstanding streaming RPC was not cancelled.

This likely applies to both client-side and server-side; I only verified it broken on server-side.


Changed files:
netty/src/test/java/io/grpc/netty/NettyServerHandlerTest.java, netty/src/main/java/io/grpc/netty/NettyServerHandler.java

diff --git a/netty/src/main/java/io/grpc/netty/NettyServerHandler.java b/netty/src/main/java/io/grpc/netty/NettyServerHandler.java
index e7d6ea2dd..06b5a3fb9 100644
--- a/netty/src/main/java/io/grpc/netty/NettyServerHandler.java
+++ b/netty/src/main/java/io/grpc/netty/NettyServerHandler.java
@@ -261,18 +261,21 @@ class NettyServerHandler extends AbstractNettyHandler {
    */
   @Override
   public void channelInactive(ChannelHandlerContext ctx) throws Exception {
-    super.channelInactive(ctx);
-    // Any streams that are still active must be closed
-    connection().forEachActiveStream(new Http2StreamVisitor() {
-      @Override
-      public boolean visit(Http2Stream stream) throws Http2Exception {
-        NettyServerStream serverStream = serverStream(stream);
-        if (serverStream != null) {
-          serverStream.abortStream(GOAWAY_STATUS, false);
+    try {
+      // Any streams that are still active must be closed
+      connection().forEachActiveStream(new Http2StreamVisitor() {
+        @Override
+        public boolean visit(Http2Stream stream) throws Http2Exception {
+          NettyServerStream serverStream = serverStream(stream);
+          if (serverStream != null) {
+            serverStream.abortStream(GOAWAY_STATUS, false);
+          }
+          return true;
         }
-        return true;
-      }
-    });
+      });
+    } finally {
+      super.channelInactive(ctx);
+    }
   }
 
   WriteQueue getWriteQueue() {
diff --git a/netty/src/test/java/io/grpc/netty/NettyServerHandlerTest.java b/netty/src/test/java/io/grpc/netty/NettyServerHandlerTest.java
index 87078c2a4..52ec3fd40 100644
--- a/netty/src/test/java/io/grpc/netty/NettyServerHandlerTest.java
+++ b/netty/src/test/java/io/grpc/netty/NettyServerHandlerTest.java
@@ -237,6 +237,15 @@ public class NettyServerHandlerTest extends NettyHandlerTestBase<NettyServerHand
     assertFalse(channel().isOpen());
   }
 
+  @Test
+  public void channelInactiveShouldCloseStreams() throws Exception {
+    createStream();
+    handler().channelInactive(ctx());
+    ArgumentCaptor<Status> captor = ArgumentCaptor.forClass(Status.class);
+    verify(streamListener).closed(captor.capture());
+    assertFalse(captor.getValue().isOk());
+  }
+
   @Test
   public void shouldAdvertiseMaxConcurrentStreams() throws Exception {
     maxConcurrentStreams = 314;
Repository: grpc/grpc-java
Issue: Netty Server does not observe channelInactive

If the TCP connection goes down, gRPC isn't noticing because nothing is observing the `channelInactive()` notification on the channel pipeline. I confirmed that `channelInactive()` is called, but saw that an outstanding streaming RPC was not cancelled.

This likely applies to both client-side and server-side; I only verified it broken on server-side.


Changed files:
netty/src/test/java/io/grpc/netty/NettyServerHandlerTest.java, netty/src/main/java/io/grpc/netty/NettyServerHandler.java

diff --git a/netty/src/main/java/io/grpc/netty/NettyServerHandler.java b/netty/src/main/java/io/grpc/netty/NettyServerHandler.java
index 94f287629..7e53e731a 100644
--- a/netty/src/main/java/io/grpc/netty/NettyServerHandler.java
+++ b/netty/src/main/java/io/grpc/netty/NettyServerHandler.java
@@ -224,15 +224,18 @@ class NettyServerHandler extends Http2ConnectionHandler {
    */
   @Override
   public void channelInactive(ChannelHandlerContext ctx) throws Exception {
-    super.channelInactive(ctx);
-    // Any streams that are still active must be closed
-    connection().forEachActiveStream(new Http2StreamVisitor() {
-      @Override
-      public boolean visit(Http2Stream stream) throws Http2Exception {
-        serverStream(stream).abortStream(GOAWAY_STATUS, false);
-        return true;
-      }
-    });
+    try {
+      // Any streams that are still active must be closed
+      connection().forEachActiveStream(new Http2StreamVisitor() {
+        @Override
+        public boolean visit(Http2Stream stream) throws Http2Exception {
+          serverStream(stream).abortStream(GOAWAY_STATUS, false);
+          return true;
+        }
+      });
+    } finally {
+      super.channelInactive(ctx);
+    }
   }
 
   WriteQueue getWriteQueue() {
diff --git a/netty/src/test/java/io/grpc/netty/NettyServerHandlerTest.java b/netty/src/test/java/io/grpc/netty/NettyServerHandlerTest.java
index 7293907ea..b3a99f228 100644
--- a/netty/src/test/java/io/grpc/netty/NettyServerHandlerTest.java
+++ b/netty/src/test/java/io/grpc/netty/NettyServerHandlerTest.java
@@ -249,6 +249,15 @@ public class NettyServerHandlerTest extends NettyHandlerTestBase<NettyServerHand
     assertFalse(channel().isOpen());
   }
 
+  @Test
+  public void channelInactiveShouldCloseStreams() throws Exception {
+    createStream();
+    handler().channelInactive(ctx());
+    ArgumentCaptor<Status> captor = ArgumentCaptor.forClass(Status.class);
+    verify(streamListener).closed(captor.capture());
+    assertFalse(captor.getValue().isOk());
+  }
+
   @Test
   public void shouldAdvertiseMaxConcurrentStreams() throws Exception {
     maxConcurrentStreams = 314;
Repository: grpc/grpc-java
Issue: Http2ClientStream overwrites error message

[Http2ClientStream.transportHeadersReceived()](https://github.com/grpc/grpc-java/blob/d0aad72441f2f110910003599bb923db6f671f02/core/src/main/java/io/grpc/transport/Http2ClientStream.java#L102) is calling withDescription instead of augmentDescription. This hinders debugging what went wrong.

@yang-g, since he is interested in when this is resolved.


Changed files:
core/src/main/java/io/grpc/transport/Http2ClientStream.java

diff --git a/core/src/main/java/io/grpc/transport/Http2ClientStream.java b/core/src/main/java/io/grpc/transport/Http2ClientStream.java
index badc7c0f2..85577cc8f 100644
--- a/core/src/main/java/io/grpc/transport/Http2ClientStream.java
+++ b/core/src/main/java/io/grpc/transport/Http2ClientStream.java
@@ -99,7 +99,7 @@ public abstract class Http2ClientStream extends AbstractClientStream<Integer> {
     if (transportError != null) {
       // Note we don't immediately report the transport error, instead we wait for more data on the
       // stream so we can accumulate more detail into the error before reporting it.
-      transportError = transportError.withDescription("\\n" + headers.toString());
+      transportError = transportError.augmentDescription("\\n" + headers.toString());
       errorCharset = extractCharset(headers);
     } else {
       stripTransportDetails(headers);
Repository: grpc/grpc-java
Issue: Fix UNKNOWN status without description

https://github.com/grpc/grpc-java/blob/d2b1b37ed7ba0087fd8a2920549118191ce22f95/core/src/main/java/io/grpc/ChannelImpl.java#L311
https://github.com/grpc/grpc-java/blob/3e26b993ce90901b32faa1b8b855abfdc2153bc6/netty/src/main/java/io/grpc/transport/netty/NettyClientHandler.java#L212

We should basically always provide a description, so that users have a hope of distinguishing whether an error is local or remote. The NettyClientHandler should be converting the HTTP/2 error code to a status.


Changed files:
core/src/main/java/io/grpc/ChannelImpl.java, netty/src/main/java/io/grpc/transport/netty/NettyClientHandler.java

diff --git a/core/src/main/java/io/grpc/ChannelImpl.java b/core/src/main/java/io/grpc/ChannelImpl.java
index 4e4acebb7..c50950d1a 100644
--- a/core/src/main/java/io/grpc/ChannelImpl.java
+++ b/core/src/main/java/io/grpc/ChannelImpl.java
@@ -308,7 +308,7 @@ public final class ChannelImpl extends Channel {
           activeTransport = null;
         }
         // TODO(notcarl): replace this with something more meaningful
-        transportShutdown(Status.UNKNOWN);
+        transportShutdown(Status.UNKNOWN.withDescription("transport shutdown for unknown reason"));
         transports.remove(transport);
         if (shutdown && transports.isEmpty()) {
           if (terminated) {
diff --git a/netty/src/main/java/io/grpc/transport/netty/NettyClientHandler.java b/netty/src/main/java/io/grpc/transport/netty/NettyClientHandler.java
index 7e73a392d..1f169179d 100644
--- a/netty/src/main/java/io/grpc/transport/netty/NettyClientHandler.java
+++ b/netty/src/main/java/io/grpc/transport/netty/NettyClientHandler.java
@@ -205,11 +205,10 @@ class NettyClientHandler extends Http2ConnectionHandler {
   /**
    * Handler for an inbound HTTP/2 RST_STREAM frame, terminating a stream.
    */
-  private void onRstStreamRead(int streamId)
-      throws Http2Exception {
-    // TODO(nmittler): do something with errorCode?
+  private void onRstStreamRead(int streamId, long errorCode) throws Http2Exception {
     NettyClientStream stream = clientStream(requireHttp2Stream(streamId));
-    stream.transportReportStatus(Status.UNKNOWN, false, new Metadata.Trailers());
+    Status status = HttpUtil.Http2Error.statusForCode((int) errorCode);
+    stream.transportReportStatus(status, false, new Metadata.Trailers());
   }
 
   @Override
@@ -524,7 +523,7 @@ class NettyClientHandler extends Http2ConnectionHandler {
     @Override
     public void onRstStreamRead(ChannelHandlerContext ctx, int streamId, long errorCode)
         throws Http2Exception {
-      handler.onRstStreamRead(streamId);
+      handler.onRstStreamRead(streamId, errorCode);
     }
 
     @Override public void onPingAckRead(ChannelHandlerContext ctx, ByteBuf data)
Repository: grpc/grpc-java
Issue: ClientAuthInterceptor synchronizes on wrong object

The "this" in synchronized (this), is not the correct object to synchronize on:
https://github.com/grpc/grpc-java/blob/master/auth/src/main/java/io/grpc/auth/ClientAuthInterceptor.java#L77

It should be ClientAuthInterceptor.this instead. As the code stands, there is no synchronization between threads so you can see NullPointerExceptions as lastMetadata is set but not cached.


Changed files:
auth/src/main/java/io/grpc/auth/ClientAuthInterceptor.java

diff --git a/auth/src/main/java/io/grpc/auth/ClientAuthInterceptor.java b/auth/src/main/java/io/grpc/auth/ClientAuthInterceptor.java
index 17c3aaec5..3351aa715 100644
--- a/auth/src/main/java/io/grpc/auth/ClientAuthInterceptor.java
+++ b/auth/src/main/java/io/grpc/auth/ClientAuthInterceptor.java
@@ -74,7 +74,8 @@ public class ClientAuthInterceptor implements ClientInterceptor {
       @Override
       public void start(Listener<RespT> responseListener, Metadata.Headers headers) {
         try {
-          synchronized (this) {
+          Metadata.Headers cachedSaved;
+          synchronized (ClientAuthInterceptor.this) {
             // TODO(lryan): This is icky but the current auth library stores the same
             // metadata map until the next refresh cycle. This will be fixed once
             // https://github.com/google/google-auth-library-java/issues/3
@@ -83,8 +84,9 @@ public class ClientAuthInterceptor implements ClientInterceptor {
               lastMetadata = credentials.getRequestMetadata();
               cached = toHeaders(lastMetadata);
             }
+            cachedSaved = cached;
           }
-          headers.merge(cached);
+          headers.merge(cachedSaved);
           super.start(responseListener, headers);
         } catch (IOException ioe) {
           responseListener.onClose(Status.fromThrowable(ioe), new Metadata.Trailers());
@@ -105,4 +107,4 @@ public class ClientAuthInterceptor implements ClientInterceptor {
     }
     return headers;
   }
-}
\\ No newline at end of file
+}
Repository: grpc/grpc-java
Issue: Lacking preconditions for start() in ChannelImpl.CallImpl

For instance, calling request() before start() has been called results in a NullPointerException.


Changed files:
core/src/main/java/io/grpc/ChannelImpl.java

diff --git a/core/src/main/java/io/grpc/ChannelImpl.java b/core/src/main/java/io/grpc/ChannelImpl.java
index 033de038a..8baf9824f 100644
--- a/core/src/main/java/io/grpc/ChannelImpl.java
+++ b/core/src/main/java/io/grpc/ChannelImpl.java
@@ -265,6 +265,7 @@ public final class ChannelImpl implements Channel {
 
     @Override
     public void request(int numMessages) {
+      Preconditions.checkState(stream != null, "Not started");
       stream.request(numMessages);
     }
Repository: grpc/grpc-java
Issue: Race in Server handler initialization

When initializing an incoming client connection, [we call startAsync()](https://github.com/grpc/grpc-java/blob/master/netty/src/main/java/io/grpc/transport/netty/NettyServer.java#L84) on the transport, which [registers the handler](https://github.com/grpc/grpc-java/blob/master/netty/src/main/java/io/grpc/transport/netty/NettyServerTransport.java#L108) on a separate thread. This is obviously a race, and it would have probably been fixed if I had finished Service removal in #35.

Symptom:

```
DEBUG i.n.channel.DefaultChannelPipeline - Discarded inbound message SimpleLeakAwareByteBuf(PooledUnsafeDirectByteBuf(ridx: 0, widx: 259, cap: 1024)) that reached at the tail of the pipeline. Please check your pipeline configuration.
```

The quickest fix would be to call awaitRunning() from initChannel(). That reduces the rate new connections can connect, but is probably the most expedient solution, until #35 is finished.

@nmittler, thoughts?


Changed files:
netty/src/main/java/io/grpc/transport/netty/NettyServer.java

diff --git a/netty/src/main/java/io/grpc/transport/netty/NettyServer.java b/netty/src/main/java/io/grpc/transport/netty/NettyServer.java
index a96dce64b..c2c252789 100644
--- a/netty/src/main/java/io/grpc/transport/netty/NettyServer.java
+++ b/netty/src/main/java/io/grpc/transport/netty/NettyServer.java
@@ -81,7 +81,10 @@ public class NettyServer extends AbstractService {
       @Override
       public void initChannel(Channel ch) throws Exception {
         NettyServerTransport transport = new NettyServerTransport(ch, serverListener, sslContext);
-        transport.startAsync();
+        // TODO(ejona86): Ideally we wouldn't handle handler registration asyncly and then be forced
+        // to block for completion on another thread. This should be resolved as part of removing
+        // Service from server transport.
+        transport.startAsync().awaitRunning();
         // TODO(nmittler): Should we wait for transport shutdown before shutting down server?
       }
     };
Repository: grpc/grpc-java
Issue: OkHttpClientTransport.onGoAway() races with startPendingStreams()

onGoAway has two phases: do things necessary under lock and final cleanup. In the first phase it collects the streams to terminate in the second and sets goAway.

startPendingStreams() does not observe goAway and also creates new streams that should be failed due to the goAway. From an initial look, it seems it would be best to remove failPendingStreams() and simply integrate its two phases into onGoAway()'s two phases; that is, when holding the lock in onGoAway, replace pendingStreams with an empty list, and then when not holding the lock call transportReportStatus


Changed files:
okhttp/src/main/java/io/grpc/transport/okhttp/OkHttpClientTransport.java

diff --git a/okhttp/src/main/java/io/grpc/transport/okhttp/OkHttpClientTransport.java b/okhttp/src/main/java/io/grpc/transport/okhttp/OkHttpClientTransport.java
index 0e37a3884..04fd3612e 100644
--- a/okhttp/src/main/java/io/grpc/transport/okhttp/OkHttpClientTransport.java
+++ b/okhttp/src/main/java/io/grpc/transport/okhttp/OkHttpClientTransport.java
@@ -279,19 +279,6 @@ public class OkHttpClientTransport implements ClientTransport {
     return hasStreamStarted;
   }
 
-  private void failPendingStreams(Status status) {
-    LinkedList<PendingStream> streams;
-    synchronized (lock) {
-      streams = pendingStreams;
-      pendingStreams = new LinkedList<PendingStream>();
-    }
-    for (PendingStream stream : streams) {
-      stream.clientStream.transportReportStatus(
-          status, true, new Metadata.Trailers());
-      stream.createdFuture.set(null);
-    }
-  }
-
   @Override
   public void start(Listener listener) {
     this.listener = Preconditions.checkNotNull(listener, "listener");
@@ -368,6 +355,7 @@ public class OkHttpClientTransport implements ClientTransport {
   private void onGoAway(int lastKnownStreamId, Status status) {
     boolean notifyShutdown;
     ArrayList<OkHttpClientStream> goAwayStreams = new ArrayList<OkHttpClientStream>();
+    List<PendingStream> pendingStreamsCopy;
     synchronized (lock) {
       notifyShutdown = !goAway;
       goAway = true;
@@ -382,6 +370,9 @@ public class OkHttpClientTransport implements ClientTransport {
           }
         }
       }
+
+      pendingStreamsCopy = pendingStreams;
+      pendingStreams = new LinkedList<PendingStream>();
     }
 
     if (notifyShutdown) {
@@ -390,7 +381,12 @@ public class OkHttpClientTransport implements ClientTransport {
     for (OkHttpClientStream stream : goAwayStreams) {
       stream.transportReportStatus(status, false, new Metadata.Trailers());
     }
-    failPendingStreams(status);
+
+    for (PendingStream stream : pendingStreamsCopy) {
+      stream.clientStream.transportReportStatus(
+          status, true, new Metadata.Trailers());
+      stream.createdFuture.set(null);
+    }
     stopIfNecessary();
   }
Repository: grpc/grpc-java
Issue: The run-test-server.sh exits immediately

After changing to using daemon threads by default, this script stopped working.  We need to update the server to keep alive until cancelled (e.g. ctrl+c).


Changed files:
interop-testing/src/main/java/io/grpc/testing/integration/TestServiceServer.java

diff --git a/interop-testing/src/main/java/io/grpc/testing/integration/TestServiceServer.java b/interop-testing/src/main/java/io/grpc/testing/integration/TestServiceServer.java
index 07ebefec6..f994c2cd5 100644
--- a/interop-testing/src/main/java/io/grpc/testing/integration/TestServiceServer.java
+++ b/interop-testing/src/main/java/io/grpc/testing/integration/TestServiceServer.java
@@ -74,6 +74,7 @@ public class TestServiceServer {
     });
     server.start();
     System.out.println("Server started on port " + server.port);
+    server.blockUntilShutdown();
   }
 
   private int port = 8080;
@@ -152,4 +153,13 @@ public class TestServiceServer {
     }
     MoreExecutors.shutdownAndAwaitTermination(executor, 5, TimeUnit.SECONDS);
   }
+
+  /**
+   * Await termination on the main thread since the grpc library uses daemon threads.
+   */
+  private void blockUntilShutdown() throws InterruptedException {
+    if (server != null) {
+      server.awaitTermination();
+    }
+  }
 }
Repository: grpc/grpc-java
Issue: Possible race condition ServerImpl between start() and shutdown()

I believe it may be possible if start and stop are called concurrently that the shared executor may not get released.  I'm not sure if this is an actual problem, but it does go against the @ ThreadSafe annotation.


Changed files:
core/src/main/java/io/grpc/internal/ServerImpl.java

diff --git a/core/src/main/java/io/grpc/internal/ServerImpl.java b/core/src/main/java/io/grpc/internal/ServerImpl.java
index 80523832f..e45a6cecb 100644
--- a/core/src/main/java/io/grpc/internal/ServerImpl.java
+++ b/core/src/main/java/io/grpc/internal/ServerImpl.java
@@ -31,6 +31,7 @@
 
 package io.grpc.internal;
 
+import static com.google.common.base.Preconditions.checkState;
 import static io.grpc.internal.GrpcUtil.TIMEOUT_KEY;
 import static io.grpc.internal.GrpcUtil.TIMER_SERVICE;
 
@@ -114,9 +115,8 @@ public final class ServerImpl extends io.grpc.Server {
   @Override
   public ServerImpl start() throws IOException {
     synchronized (lock) {
-      if (started) {
-        throw new IllegalStateException("Already started");
-      }
+      checkState(!started, "Already started");
+      checkState(!shutdown, "Shutting down");
       usingSharedExecutor = executor == null;
       if (usingSharedExecutor) {
         executor = SharedResourceHolder.get(GrpcUtil.SHARED_CHANNEL_EXECUTOR);
Repository: netflix/conductor
Issue: Mismatched parameter naming for IsolationGroup

In IsolatedTaskQueueProducer
```
	@VisibleForTesting
	void addTaskQueues() {
		Set<TaskDef> isolationTaskDefs = getIsolationExecutionNameSpaces();
		logger.debug("Retrieved queues {}", isolationTaskDefs);
		Set<String> taskTypes = SystemTaskWorkerCoordinator.taskNameWorkflowTaskMapping.keySet();

		for (TaskDef isolatedTaskDef : isolationTaskDefs) {
			for (String taskType : taskTypes) {
				String taskQueue = QueueUtils.getQueueName(taskType, null,
					isolatedTaskDef.getExecutionNameSpace(), isolatedTaskDef.getIsolationGroupId());
				logger.debug("Adding taskQueue:'{}' to system task worker coordinator", taskQueue);
				SystemTaskWorkerCoordinator.queue.add(taskQueue);
			}
		}
	}
```

It gets the name for the isolated task by calling QueueUtils.getQueueName(with the following order
- taskType
- null (domain)
- isolatedTaskDef.getExecutionNameSpace() 
-  isolatedTaskDef.getIsolationGroupId()

But the signature of QueueUtils.getQueueName is like 

```
	public static String getQueueName(String taskType, String domain, String isolationGroup, String executionNameSpace) {

        ...
	}
```

The order of `isolationGroup` and `executionNameSpace` is swapped.

I think this might cause bug for IsolatedTask. Since other places are using it like 
```
	public static String getQueueName(Task task) {
		return getQueueName(task.getTaskType(), task.getDomain(), task.getIsolationGroupId(), task.getExecutionNameSpace());
	}
```

Since I haven't experimented with IsolatedTasks, sorry I can't provide ways to observe the bug.

Changed files:
core/src/main/java/com/netflix/conductor/core/execution/tasks/IsolatedTaskQueueProducer.java

diff --git a/core/src/main/java/com/netflix/conductor/core/execution/tasks/IsolatedTaskQueueProducer.java b/core/src/main/java/com/netflix/conductor/core/execution/tasks/IsolatedTaskQueueProducer.java
index ce4477c5c..46dab7916 100644
--- a/core/src/main/java/com/netflix/conductor/core/execution/tasks/IsolatedTaskQueueProducer.java
+++ b/core/src/main/java/com/netflix/conductor/core/execution/tasks/IsolatedTaskQueueProducer.java
@@ -79,7 +79,7 @@ public class IsolatedTaskQueueProducer {
 		for (TaskDef isolatedTaskDef : isolationTaskDefs) {
 			for (String taskType : taskTypes) {
 				String taskQueue = QueueUtils.getQueueName(taskType, null,
-					isolatedTaskDef.getExecutionNameSpace(), isolatedTaskDef.getIsolationGroupId());
+					isolatedTaskDef.getIsolationGroupId(), isolatedTaskDef.getExecutionNameSpace());
 				logger.debug("Adding taskQueue:'{}' to system task worker coordinator", taskQueue);
 				SystemTaskWorkerCoordinator.queue.add(taskQueue);
 			}
Repository: netflix/conductor
Issue: Complete WAIT task inside for loop by TaskRef

See discussion https://github.com/Netflix/conductor/discussions/2873 
Seems like it was partially fixed https://github.com/Netflix/conductor/pull/2883 for eventhandler actions, but did not get fixed for default WAIT task handlers.


Changed files:
core/src/main/java/com/netflix/conductor/core/events/queue/DefaultEventQueueProcessor.java

diff --git a/core/src/main/java/com/netflix/conductor/core/events/queue/DefaultEventQueueProcessor.java b/core/src/main/java/com/netflix/conductor/core/events/queue/DefaultEventQueueProcessor.java
index 78abf836b..f1c508803 100644
--- a/core/src/main/java/com/netflix/conductor/core/events/queue/DefaultEventQueueProcessor.java
+++ b/core/src/main/java/com/netflix/conductor/core/events/queue/DefaultEventQueueProcessor.java
@@ -22,6 +22,7 @@ import org.springframework.stereotype.Component;
 
 import com.netflix.conductor.common.metadata.tasks.Task;
 import com.netflix.conductor.common.metadata.tasks.TaskResult;
+import com.netflix.conductor.common.utils.TaskUtils;
 import com.netflix.conductor.core.exception.NotFoundException;
 import com.netflix.conductor.core.execution.WorkflowExecutor;
 import com.netflix.conductor.model.TaskModel;
@@ -124,7 +125,10 @@ public class DefaultEventQueueProcessor {
                                                     .filter(
                                                             task ->
                                                                     !task.getStatus().isTerminal()
-                                                                            && task.getReferenceTaskName()
+                                                                            && TaskUtils
+                                                                                    .removeIterationFromTaskRefName(
+                                                                                            task
+                                                                                                    .getReferenceTaskName())
                                                                                     .equals(
                                                                                             taskRefName))
                                                     .findFirst();