You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2020/12/06 10:09:24 UTC

[httpcomponents-core] branch 5.2.x updated: Added default `ConnectionAcceptor#listen` method that takes an optional attachment as a parameter

This is an automated email from the ASF dual-hosted git repository.

olegk pushed a commit to branch 5.2.x
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git


The following commit(s) were added to refs/heads/5.2.x by this push:
     new c9c7d32  Added default `ConnectionAcceptor#listen` method that takes an optional attachment as a parameter
c9c7d32 is described below

commit c9c7d32f70491cafe2c97cf04e29220daa734f72
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Sun Dec 6 11:04:29 2020 +0100

    Added default `ConnectionAcceptor#listen` method that takes an optional attachment as a parameter
---
 .../hc/core5/http/impl/bootstrap/AsyncServer.java  |  4 +-
 .../hc/core5/reactor/ConnectionAcceptor.java       | 21 +++++-
 .../hc/core5/reactor/ConnectionListener.java       | 80 ----------------------
 .../core5/reactor/DefaultListeningIOReactor.java   |  6 +-
 .../reactor/SingleCoreListeningIOReactor.java      |  2 +-
 pom.xml                                            |  7 ++
 6 files changed, 30 insertions(+), 90 deletions(-)

diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/AsyncServer.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/AsyncServer.java
index 8a5c040..e776af1 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/AsyncServer.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/AsyncServer.java
@@ -40,7 +40,6 @@ import org.apache.hc.core5.function.Decorator;
 import org.apache.hc.core5.io.CloseMode;
 import org.apache.hc.core5.reactor.ConnectionAcceptor;
 import org.apache.hc.core5.reactor.ConnectionInitiator;
-import org.apache.hc.core5.reactor.ConnectionListener;
 import org.apache.hc.core5.reactor.DefaultListeningIOReactor;
 import org.apache.hc.core5.reactor.IOEventHandlerFactory;
 import org.apache.hc.core5.reactor.IOReactorConfig;
@@ -54,8 +53,7 @@ import org.apache.hc.core5.util.TimeValue;
 /**
  * Protocol agnostic server side I/O session handler.
  */
-public class AsyncServer extends AbstractConnectionInitiatorBase
-        implements IOReactorService, ConnectionListener, ConnectionAcceptor {
+public class AsyncServer extends AbstractConnectionInitiatorBase implements IOReactorService, ConnectionAcceptor {
 
     private final DefaultListeningIOReactor ioReactor;
 
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/ConnectionAcceptor.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/ConnectionAcceptor.java
index 490287b..07d601b 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/ConnectionAcceptor.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/ConnectionAcceptor.java
@@ -38,10 +38,7 @@ import org.apache.hc.core5.concurrent.FutureCallback;
  * Non-blocking connection acceptor.
  *
  * @since 5.0
- *
- * @deprecated Use {@link ConnectionListener}
  */
-@Deprecated
 public interface ConnectionAcceptor {
 
     /**
@@ -51,6 +48,24 @@ public interface ConnectionAcceptor {
      * dispatcher.
      *
      * @param address the socket address to listen on.
+     * @param attachment the attachment object.
+     * @param callback the result callback.
+     * @return listener endpoint.
+     *
+     * @since 5.2
+     */
+    default Future<ListenerEndpoint> listen(
+            SocketAddress address, Object attachment, FutureCallback<ListenerEndpoint> callback) {
+        return listen(address, callback);
+    }
+
+    /**
+     * Opens a new listener endpoint with the given socket address. Once
+     * the endpoint is fully initialized it starts accepting incoming
+     * connections and propagates I/O activity notifications to the I/O event
+     * dispatcher.
+     *
+     * @param address the socket address to listen on.
      * @param callback the result callback.
      * @return listener endpoint.
      */
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/ConnectionListener.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/ConnectionListener.java
deleted file mode 100644
index a70ac50..0000000
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/ConnectionListener.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- */
-
-package org.apache.hc.core5.reactor;
-
-import java.io.IOException;
-import java.net.SocketAddress;
-import java.util.Set;
-import java.util.concurrent.Future;
-
-import org.apache.hc.core5.concurrent.FutureCallback;
-
-/**
- * Non-blocking connection acceptor.
- *
- * @since 5.1
- */
-public interface ConnectionListener {
-
-    /**
-     * Opens a new listener endpoint with the given socket address. Once
-     * the endpoint is fully initialized it starts accepting incoming
-     * connections and propagates I/O activity notifications to the I/O event
-     * dispatcher.
-     *
-     * @param address the socket address to listen on.
-     * @param attachment the attachment object.
-     * @param callback the result callback.
-     * @return listener endpoint.
-     */
-    Future<ListenerEndpoint> listen(SocketAddress address, Object attachment, FutureCallback<ListenerEndpoint> callback);
-
-    /**
-     * Suspends the I/O reactor preventing it from accepting new connections on
-     * all active endpoints.
-     *
-     * @throws IOException in case of an I/O error.
-     */
-    void pause() throws IOException;
-
-    /**
-     * Resumes the I/O reactor restoring its ability to accept incoming
-     * connections on all active endpoints.
-     *
-     * @throws IOException in case of an I/O error.
-     */
-    void resume() throws IOException;
-
-    /**
-     * Returns a set of endpoints for this I/O reactor.
-     *
-     * @return set of endpoints.
-     */
-    Set<ListenerEndpoint> getEndpoints();
-
-}
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/DefaultListeningIOReactor.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/DefaultListeningIOReactor.java
index 515bdeb..fe96775 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/DefaultListeningIOReactor.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/DefaultListeningIOReactor.java
@@ -42,15 +42,15 @@ import org.apache.hc.core5.util.Args;
 import org.apache.hc.core5.util.TimeValue;
 
 /**
- * Multi-core I/O reactor that can ask as both {@link ConnectionInitiator}
- * and {@link ConnectionListener}. Internally this I/O reactor distributes newly created
+ * Multi-core I/O reactor that can act as both {@link ConnectionInitiator}
+ * and {@link ConnectionAcceptor}. Internally this I/O reactor distributes newly created
  * I/O session equally across multiple I/O worker threads for a more optimal resource
  * utilization and a better I/O performance. Usually it is recommended to have
  * one worker I/O reactor per physical CPU core.
  *
  * @since 4.0
  */
-public class DefaultListeningIOReactor extends AbstractIOReactorBase implements ConnectionListener, ConnectionAcceptor {
+public class DefaultListeningIOReactor extends AbstractIOReactorBase implements ConnectionAcceptor {
 
     private final static ThreadFactory DISPATCH_THREAD_FACTORY = new DefaultThreadFactory("I/O server dispatch", true);
     private final static ThreadFactory LISTENER_THREAD_FACTORY = new DefaultThreadFactory("I/O listener", true);
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/SingleCoreListeningIOReactor.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/SingleCoreListeningIOReactor.java
index d3603b8..a06b66d 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/SingleCoreListeningIOReactor.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/SingleCoreListeningIOReactor.java
@@ -50,7 +50,7 @@ import org.apache.hc.core5.concurrent.FutureCallback;
 import org.apache.hc.core5.function.Callback;
 import org.apache.hc.core5.io.Closer;
 
-class SingleCoreListeningIOReactor extends AbstractSingleCoreIOReactor implements ConnectionListener, ConnectionAcceptor {
+class SingleCoreListeningIOReactor extends AbstractSingleCoreIOReactor implements ConnectionAcceptor {
 
     private final IOReactorConfig reactorConfig;
     private final Callback<ChannelEntry> callback;
diff --git a/pom.xml b/pom.xml
index 54a469f..f91d599 100644
--- a/pom.xml
+++ b/pom.xml
@@ -176,6 +176,13 @@
           <parameter>
             <breakBuildOnBinaryIncompatibleModifications>true</breakBuildOnBinaryIncompatibleModifications>
             <breakBuildOnSourceIncompatibleModifications>true</breakBuildOnSourceIncompatibleModifications>
+            <overrideCompatibilityChangeParameters>
+              <overrideCompatibilityChangeParameter>
+                <compatibilityChange>METHOD_NEW_DEFAULT</compatibilityChange>
+                <binaryCompatible>true</binaryCompatible>
+                <sourceCompatible>true</sourceCompatible>
+              </overrideCompatibilityChangeParameter>
+            </overrideCompatibilityChangeParameters>
             <excludes>
               <exclude>@org.apache.hc.core5.annotation.Internal</exclude>
             </excludes>