This is an automated email from the ASF dual-hosted git repository.
alenka pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new 618ef501a2 GH-45922: [C++][Flight] Remove deprecated Authenticate and
StartCall (#45932)
618ef501a2 is described below
commit 618ef501a21375abfaeee19e393eb64dee83ef0d
Author: Alenka Frim <[email protected]>
AuthorDate: Fri Mar 28 13:53:14 2025 +0100
GH-45922: [C++][Flight] Remove deprecated Authenticate and StartCall
(#45932)
### Rationale for this change
[Authenticate](https://github.com/apache/arrow/blob/c124bb55d993daca93742ce896869ab3101dccbb/cpp/src/arrow/flight/server_auth.h#L76)
and
[StartCall](https://github.com/apache/arrow/blob/c124bb55d993daca93742ce896869ab3101dccbb/cpp/src/arrow/flight/server_middleware.h#L94)
have been deprecated in 13.0.0 and can now be removed.
### What changes are included in this PR?
`ServerAuthHandler.Authenticate` and `ServerMiddlewareFactory.StartCall`
versions without `ServerCallContext` are removed.
### Are these changes tested?
Existing tests should pass.
### Are there any user-facing changes?
Deprecated Flight functionality is removed.
* GitHub Issue: #45922
Authored-by: AlenkaF <[email protected]>
Signed-off-by: AlenkaF <[email protected]>
---
cpp/src/arrow/flight/CMakeLists.txt | 1 -
cpp/src/arrow/flight/server_auth.h | 20 +------------
cpp/src/arrow/flight/server_middleware.cc | 35 ----------------------
cpp/src/arrow/flight/server_middleware.h | 24 +--------------
.../arrow/flight/sql/server_session_middleware.cc | 11 +++----
.../flight/sql/server_session_middleware_factory.h | 2 +-
python/pyarrow/src/arrow/python/flight.cc | 9 +++---
python/pyarrow/src/arrow/python/flight.h | 5 ++--
8 files changed, 17 insertions(+), 90 deletions(-)
diff --git a/cpp/src/arrow/flight/CMakeLists.txt
b/cpp/src/arrow/flight/CMakeLists.txt
index 7f86d51e20..818f731f16 100644
--- a/cpp/src/arrow/flight/CMakeLists.txt
+++ b/cpp/src/arrow/flight/CMakeLists.txt
@@ -146,7 +146,6 @@ set(ARROW_FLIGHT_SRCS
serialization_internal.cc
server.cc
server_auth.cc
- server_middleware.cc
server_tracing_middleware.cc
transport.cc
transport_server.cc
diff --git a/cpp/src/arrow/flight/server_auth.h
b/cpp/src/arrow/flight/server_auth.h
index 93d3352ba2..147bef68d0 100644
--- a/cpp/src/arrow/flight/server_auth.h
+++ b/cpp/src/arrow/flight/server_auth.h
@@ -61,25 +61,7 @@ class ARROW_FLIGHT_EXPORT ServerAuthHandler {
/// \param[in] incoming The reader for messages from the client.
/// \return Status OK if this authentication is succeeded.
virtual Status Authenticate(const ServerCallContext& context,
- ServerAuthSender* outgoing, ServerAuthReader*
incoming) {
- // TODO: We can make this pure virtual function when we remove
- // the deprecated version.
- ARROW_SUPPRESS_DEPRECATION_WARNING
- return Authenticate(outgoing, incoming);
- ARROW_UNSUPPRESS_DEPRECATION_WARNING
- }
- /// \brief Authenticate the client on initial connection. The server
- /// can send and read responses from the client at any time.
- /// \param[in] outgoing The writer for messages to the client.
- /// \param[in] incoming The reader for messages from the client.
- /// \return Status OK if this authentication is succeeded.
- /// \deprecated Deprecated in 13.0.0. Implement the Authentication()
- /// with ServerCallContext version instead.
- ARROW_DEPRECATED("Deprecated in 13.0.0. Use ServerCallContext overload
instead.")
- virtual Status Authenticate(ServerAuthSender* outgoing, ServerAuthReader*
incoming) {
- return Status::NotImplemented(typeid(this).name(),
- "::Authenticate() isn't implemented");
- }
+ ServerAuthSender* outgoing, ServerAuthReader*
incoming) = 0;
/// \brief Validate a per-call client token.
/// \param[in] context The call context.
/// \param[in] token The client token. May be the empty string if
diff --git a/cpp/src/arrow/flight/server_middleware.cc
b/cpp/src/arrow/flight/server_middleware.cc
deleted file mode 100644
index d7ace580dc..0000000000
--- a/cpp/src/arrow/flight/server_middleware.cc
+++ /dev/null
@@ -1,35 +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.
-
-#include "arrow/flight/server_middleware.h"
-#include "arrow/flight/server.h"
-
-namespace arrow {
-namespace flight {
-
-Status ServerMiddlewareFactory::StartCall(const CallInfo& info,
- const ServerCallContext& context,
- std::shared_ptr<ServerMiddleware>*
middleware) {
- // TODO: We can make this pure virtual function when we remove
- // the deprecated version.
- ARROW_SUPPRESS_DEPRECATION_WARNING
- return StartCall(info, context.incoming_headers(), middleware);
- ARROW_UNSUPPRESS_DEPRECATION_WARNING
-}
-
-} // namespace flight
-} // namespace arrow
diff --git a/cpp/src/arrow/flight/server_middleware.h
b/cpp/src/arrow/flight/server_middleware.h
index 3a3e6f8616..3a0f3c4750 100644
--- a/cpp/src/arrow/flight/server_middleware.h
+++ b/cpp/src/arrow/flight/server_middleware.h
@@ -75,29 +75,7 @@ class ARROW_FLIGHT_EXPORT ServerMiddlewareFactory {
/// their CallCompleted callback called. Other middleware
/// factories will not be called.
virtual Status StartCall(const CallInfo& info, const ServerCallContext&
context,
- std::shared_ptr<ServerMiddleware>* middleware);
-
- /// \brief A callback for the start of a new call.
- ///
- /// Return a non-OK status to reject the call with the given status.
- ///
- /// \param info Information about the call.
- /// \param incoming_headers Headers sent by the client for this call.
- /// Do not retain a reference to this object.
- /// \param[out] middleware The middleware instance for this call. If
- /// null, no middleware will be added to this call instance from
- /// this factory.
- /// \return Status A non-OK status will reject the call with the
- /// given status. Middleware previously in the chain will have
- /// their CallCompleted callback called. Other middleware
- /// factories will not be called.
- /// \deprecated Deprecated in 13.0.0. Implement the StartCall()
- /// with ServerCallContext version instead.
- ARROW_DEPRECATED("Deprecated in 13.0.0. Use ServerCallContext overload
instead.")
- virtual Status StartCall(const CallInfo& info, const CallHeaders&
incoming_headers,
- std::shared_ptr<ServerMiddleware>* middleware) {
- return Status::NotImplemented(typeid(this).name(), "::StartCall() isn't
implemented");
- }
+ std::shared_ptr<ServerMiddleware>* middleware) = 0;
};
} // namespace flight
diff --git a/cpp/src/arrow/flight/sql/server_session_middleware.cc
b/cpp/src/arrow/flight/sql/server_session_middleware.cc
index 43609ea8cc..30209c2278 100644
--- a/cpp/src/arrow/flight/sql/server_session_middleware.cc
+++ b/cpp/src/arrow/flight/sql/server_session_middleware.cc
@@ -17,6 +17,7 @@
#include <mutex>
+#include "arrow/flight/server.h"
#include "arrow/flight/sql/server_session_middleware.h"
#include "arrow/flight/sql/server_session_middleware_factory.h"
@@ -134,12 +135,12 @@ ServerSessionMiddlewareFactory::ParseCookieString(const
std::string_view& s) {
}
Status ServerSessionMiddlewareFactory::StartCall(
- const CallInfo&, const CallHeaders& incoming_headers,
+ const CallInfo&, const ServerCallContext& context,
std::shared_ptr<ServerMiddleware>* middleware) {
std::string session_id;
const std::pair<CallHeaders::const_iterator, CallHeaders::const_iterator>&
- headers_it_pr = incoming_headers.equal_range("cookie");
+ headers_it_pr = context.incoming_headers().equal_range("cookie");
for (auto itr = headers_it_pr.first; itr != headers_it_pr.second; ++itr) {
const std::string_view& cookie_header = itr->second;
const std::vector<std::pair<std::string, std::string>> cookies =
@@ -158,8 +159,8 @@ Status ServerSessionMiddlewareFactory::StartCall(
// No cookie was found
// Temporary workaround until middleware handling fixed
auto [id, s] = CreateNewSession();
- *middleware = std::make_shared<ServerSessionMiddlewareImpl>(this,
incoming_headers,
- std::move(s),
id, false);
+ *middleware = std::make_shared<ServerSessionMiddlewareImpl>(
+ this, context.incoming_headers(), std::move(s), id, false);
} else {
const std::shared_lock<std::shared_mutex> l(session_store_lock_);
if (auto it = session_store_.find(session_id); it == session_store_.end())
{
@@ -167,7 +168,7 @@ Status ServerSessionMiddlewareFactory::StartCall(
} else {
auto session = it->second;
*middleware = std::make_shared<ServerSessionMiddlewareImpl>(
- this, incoming_headers, std::move(session), session_id);
+ this, context.incoming_headers(), std::move(session), session_id);
}
}
diff --git a/cpp/src/arrow/flight/sql/server_session_middleware_factory.h
b/cpp/src/arrow/flight/sql/server_session_middleware_factory.h
index 2613c572ee..ef90bc876b 100644
--- a/cpp/src/arrow/flight/sql/server_session_middleware_factory.h
+++ b/cpp/src/arrow/flight/sql/server_session_middleware_factory.h
@@ -46,7 +46,7 @@ class ARROW_FLIGHT_SQL_EXPORT ServerSessionMiddlewareFactory
public:
explicit ServerSessionMiddlewareFactory(std::function<std::string()> id_gen)
: id_generator_(id_gen) {}
- Status StartCall(const CallInfo&, const CallHeaders& incoming_headers,
+ Status StartCall(const CallInfo&, const ServerCallContext& context,
std::shared_ptr<ServerMiddleware>* middleware) override;
/// \brief Get a new, empty session option map and its id key.
diff --git a/python/pyarrow/src/arrow/python/flight.cc
b/python/pyarrow/src/arrow/python/flight.cc
index ce5e6dfa94..2fda48b70b 100644
--- a/python/pyarrow/src/arrow/python/flight.cc
+++ b/python/pyarrow/src/arrow/python/flight.cc
@@ -37,7 +37,8 @@ PyServerAuthHandler::PyServerAuthHandler(PyObject* handler,
handler_.reset(handler);
}
-Status PyServerAuthHandler::Authenticate(arrow::flight::ServerAuthSender*
outgoing,
+Status PyServerAuthHandler::Authenticate(const
arrow::flight::ServerCallContext& context,
+ arrow::flight::ServerAuthSender*
outgoing,
arrow::flight::ServerAuthReader*
incoming) {
return SafeCallIntoPython([=] {
const Status status = vtable_.authenticate(handler_.obj(), outgoing,
incoming);
@@ -267,11 +268,11 @@
PyServerMiddlewareFactory::PyServerMiddlewareFactory(PyObject* factory,
}
Status PyServerMiddlewareFactory::StartCall(
- const arrow::flight::CallInfo& info,
- const arrow::flight::CallHeaders& incoming_headers,
+ const arrow::flight::CallInfo& info, const
arrow::flight::ServerCallContext& context,
std::shared_ptr<arrow::flight::ServerMiddleware>* middleware) {
return SafeCallIntoPython([&] {
- const Status status = start_call_(factory_.obj(), info, incoming_headers,
middleware);
+ const Status status =
+ start_call_(factory_.obj(), info, context.incoming_headers(),
middleware);
RETURN_NOT_OK(CheckPyError());
return status;
});
diff --git a/python/pyarrow/src/arrow/python/flight.h
b/python/pyarrow/src/arrow/python/flight.h
index 57d21976bb..8a1f4c750a 100644
--- a/python/pyarrow/src/arrow/python/flight.h
+++ b/python/pyarrow/src/arrow/python/flight.h
@@ -114,7 +114,8 @@ class ARROW_PYFLIGHT_EXPORT PyServerAuthHandler
public:
explicit PyServerAuthHandler(PyObject* handler,
const PyServerAuthHandlerVtable& vtable);
- Status Authenticate(arrow::flight::ServerAuthSender* outgoing,
+ Status Authenticate(const arrow::flight::ServerCallContext& context,
+ arrow::flight::ServerAuthSender* outgoing,
arrow::flight::ServerAuthReader* incoming) override;
Status IsValid(const std::string& token, std::string* peer_identity)
override;
@@ -225,7 +226,7 @@ class ARROW_PYFLIGHT_EXPORT PyServerMiddlewareFactory
explicit PyServerMiddlewareFactory(PyObject* factory, StartCallCallback
start_call);
Status StartCall(const arrow::flight::CallInfo& info,
- const arrow::flight::CallHeaders& incoming_headers,
+ const arrow::flight::ServerCallContext& context,
std::shared_ptr<arrow::flight::ServerMiddleware>*
middleware) override;
private: