anon-iclr-submission/benchname-bug-localization huggingface dataset:
Repository: spring-cloud/spring-cloud-stream
Issue: AbstractAvroMessageConverter is failing due originalContentType

Currently the `AbstractAvroMessageConverter` checks for the contentType header, but it turns out that the header is set at `originalContentType`. 

We need to make sure we check both values in order to make `canConvertFrom` work properly

Changed files:
spring-cloud-stream-schema/src/main/java/org/springframework/cloud/stream/schema/avro/AbstractAvroMessageConverter.java

diff --git a/spring-cloud-stream-schema/src/main/java/org/springframework/cloud/stream/schema/avro/AbstractAvroMessageConverter.java b/spring-cloud-stream-schema/src/main/java/org/springframework/cloud/stream/schema/avro/AbstractAvroMessageConverter.java
index a1480b3c8..af544935e 100644
--- a/spring-cloud-stream-schema/src/main/java/org/springframework/cloud/stream/schema/avro/AbstractAvroMessageConverter.java
+++ b/spring-cloud-stream-schema/src/main/java/org/springframework/cloud/stream/schema/avro/AbstractAvroMessageConverter.java
@@ -37,6 +37,7 @@ import org.apache.avro.specific.SpecificDatumReader;
 import org.apache.avro.specific.SpecificDatumWriter;
 import org.apache.avro.specific.SpecificRecord;
 
+import org.springframework.cloud.stream.binder.BinderHeaders;
 import org.springframework.core.io.Resource;
 import org.springframework.messaging.Message;
 import org.springframework.messaging.MessageHeaders;
@@ -48,6 +49,7 @@ import org.springframework.util.MimeType;
  * Base class for Apache Avro
  * {@link org.springframework.messaging.converter.MessageConverter} implementations.
  * @author Marius Bogoevici
+ * @author Vinicius Carvalho
  */
 public abstract class AbstractAvroMessageConverter extends AbstractMessageConverter {
 
@@ -68,6 +70,29 @@ public abstract class AbstractAvroMessageConverter extends AbstractMessageConver
 		return super.canConvertFrom(message, targetClass) && (message.getPayload() instanceof byte[]);
 	}
 
+	@Override
+	protected boolean supportsMimeType(MessageHeaders headers) {
+
+		for (MimeType current : getSupportedMimeTypes()) {
+			if(mimeTypeMatches(current,headers.get(MessageHeaders.CONTENT_TYPE)) || mimeTypeMatches(current,headers.get(BinderHeaders.BINDER_ORIGINAL_CONTENT_TYPE)) ){
+				return true;
+			}
+		}
+
+		return false;
+	}
+
+	private boolean mimeTypeMatches(MimeType reference, Object target){
+		if(target == null){
+			return !isStrictContentTypeMatch();
+		}else if(target instanceof  MimeType){
+			return reference.equals((MimeType)target);
+		}else if(target instanceof String){
+			return reference.equals(MimeType.valueOf((String)target));
+		}
+		return false;
+	}
+
 	@Override
 	protected Object convertFromInternal(Message<?> message, Class<?> targetClass, Object conversionHint) {
 		Object result = null;
Repository: eclipse-vertx/vertx-sql-client
Issue: Recycling pooled connection events are not emitted on the eventloop context associated with connection pool

### Version

it should be only in 4.0

Currently recycling pooled connection events are not emitted on the eventloop context associated with connection pool and are emitted on the caller thread which might cause a racy access to the states of connection pool

Changed files:
vertx-pg-client/src/test/java/io/vertx/pgclient/PgPoolTestBase.java, vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/pool/ConnectionPool.java

diff --git a/vertx-pg-client/src/test/java/io/vertx/pgclient/PgPoolTestBase.java b/vertx-pg-client/src/test/java/io/vertx/pgclient/PgPoolTestBase.java
index 529e505e..0ec4f5cd 100644
--- a/vertx-pg-client/src/test/java/io/vertx/pgclient/PgPoolTestBase.java
+++ b/vertx-pg-client/src/test/java/io/vertx/pgclient/PgPoolTestBase.java
@@ -55,15 +55,15 @@ public abstract class PgPoolTestBase extends PgTestBase {
 
   @Test
   public void testPool(TestContext ctx) {
-    int num = 1000;
+    int num = 5000;
     Async async = ctx.async(num);
     PgPool pool = createPool(options, 4);
     for (int i = 0;i < num;i++) {
       pool.getConnection(ctx.asyncAssertSuccess(conn -> {
-        conn.query("SELECT id, randomnumber from WORLD WHERE id = 1").execute(ar -> {
+        conn.query("SELECT id, randomnumber from WORLD").execute(ar -> {
           if (ar.succeeded()) {
             SqlResult result = ar.result();
-            ctx.assertEquals(1, result.size());
+            ctx.assertEquals(10000, result.size());
           } else {
             ctx.assertEquals("closed", ar.cause().getMessage());
           }
@@ -80,10 +80,10 @@ public abstract class PgPoolTestBase extends PgTestBase {
     Async async = ctx.async(num);
     PgPool pool = createPool(options, 4);
     for (int i = 0;i < num;i++) {
-      pool.query("SELECT id, randomnumber from WORLD WHERE id = 1").execute(ar -> {
+      pool.query("SELECT id, randomnumber from WORLD").execute(ar -> {
         if (ar.succeeded()) {
           SqlResult result = ar.result();
-          ctx.assertEquals(1, result.size());
+          ctx.assertEquals(10000, result.size());
         } else {
           ctx.assertEquals("closed", ar.cause().getMessage());
         }
diff --git a/vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/pool/ConnectionPool.java b/vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/pool/ConnectionPool.java
index 7c92c0e2..b9c115d9 100644
--- a/vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/pool/ConnectionPool.java
+++ b/vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/pool/ConnectionPool.java
@@ -169,6 +169,14 @@ public class ConnectionPool {
 
     @Override
     public void close(Holder holder, Promise<Void> promise) {
+      if (context != null) {
+        context.dispatch(v -> doClose(holder, promise));
+      } else {
+        doClose(holder, promise);
+      }
+    }
+
+    private void doClose(Holder holder, Promise<Void> promise) {
       if (holder != this.holder) {
         String msg;
         if (this.holder == null) {
Repository: eclipse-vertx/vertx-sql-client
Issue: [vertx 4.0.0] Connection.close callback may not be called

### Version

Vertx 4.0.0

### Context

Some code working in vertx 3.9.x begin to hang.
After investigation it was comming from `connection.close().await()` (using kotlin-coroutine)
Replacing the kotlin extension `await()` by `onSuccess { ... }.onFailure{ ... }.onComplete{ ... }` showed that none is called.

### Do you have a reproducer?

No, but I think I have an explaination.

The method `close()` is called on a `ConnectionConnectionImpl`. This method create a new `Promise` then call `close(Promise ...)`
If the context is not vertx current context, it dispatch a new `close()` call in the context. But this call has no link to the promise created by the initial `close()` call.

```
@Override
  public Future<Void> close() {
    Promise<Void> promise = promise(); // new promise here
    close(promise);
    return promise.future();
  }

private void close(Promise<Void> promise) {
    if (context == Vertx.currentContext()) {
      if (tx != null) {
        tx.rollback(ar -> conn.close(this, promise));
        tx = null;
      } else {
        conn.close(this, promise);
      }
    } else {
      context.runOnContext(v -> close()); // so `promise` argument of method is never used, a close() will generate a new one
    }
  }
```


Changed files:
vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/SqlConnectionImpl.java, vertx-pg-client/src/test/java/io/vertx/pgclient/PgConnectionTestBase.java

diff --git a/vertx-pg-client/src/test/java/io/vertx/pgclient/PgConnectionTestBase.java b/vertx-pg-client/src/test/java/io/vertx/pgclient/PgConnectionTestBase.java
index 30b3f931..ab4cd49e 100644
--- a/vertx-pg-client/src/test/java/io/vertx/pgclient/PgConnectionTestBase.java
+++ b/vertx-pg-client/src/test/java/io/vertx/pgclient/PgConnectionTestBase.java
@@ -462,4 +462,20 @@ public abstract class PgConnectionTestBase extends PgClientTestBase<SqlConnectio
       });
     }));
   }
+
+  @Test
+  public void testCloseConnectionFromDifferentContext(TestContext ctx) {
+    Async done = ctx.async(1);
+    connector.accept(ctx.asyncAssertSuccess(conn -> {
+      conn.query("SELECT 1").execute(ctx.asyncAssertSuccess(res -> {
+        ctx.assertEquals(1, res.size());
+        // schedule from another context
+        new Thread(() -> {
+          conn.close(v2 -> {
+            done.complete();
+          });
+        }).start();
+      }));
+    }));
+  }
 }
diff --git a/vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/SqlConnectionImpl.java b/vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/SqlConnectionImpl.java
index a2d516a8..ff2348da 100644
--- a/vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/SqlConnectionImpl.java
+++ b/vertx-sql-client/src/main/java/io/vertx/sqlclient/impl/SqlConnectionImpl.java
@@ -149,7 +149,7 @@ public class SqlConnectionImpl<C extends SqlConnection> extends SqlConnectionBas
         conn.close(this, promise);
       }
     } else {
-      context.runOnContext(v -> close());
+      context.runOnContext(v -> close(promise));
     }
   }
 }