Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix type cast issue in transport action call #223

Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
package org.opensearch.notifications.action

import org.opensearch.action.ActionListener
import org.opensearch.action.ActionRequest
import org.opensearch.action.support.ActionFilters
import org.opensearch.client.Client
import org.opensearch.common.inject.Inject
Expand Down Expand Up @@ -63,7 +64,7 @@ internal class CreateNotificationConfigAction @Inject constructor(
*/
override fun doExecute(
task: Task?,
request: CreateNotificationConfigRequest,
request: ActionRequest,
listener: ActionListener<CreateNotificationConfigResponse>
) {
val transformedRequest = request as? CreateNotificationConfigRequest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
package org.opensearch.notifications.action

import org.opensearch.action.ActionListener
import org.opensearch.action.ActionRequest
import org.opensearch.action.support.ActionFilters
import org.opensearch.client.Client
import org.opensearch.common.inject.Inject
Expand Down Expand Up @@ -63,7 +64,7 @@ internal class DeleteNotificationConfigAction @Inject constructor(
*/
override fun doExecute(
task: Task?,
request: DeleteNotificationConfigRequest,
request: ActionRequest,
listener: ActionListener<DeleteNotificationConfigResponse>
) {
val transformedRequest = request as? DeleteNotificationConfigRequest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
package org.opensearch.notifications.action

import org.opensearch.action.ActionListener
import org.opensearch.action.ActionRequest
import org.opensearch.action.support.ActionFilters
import org.opensearch.client.Client
import org.opensearch.common.inject.Inject
Expand Down Expand Up @@ -65,7 +66,7 @@ internal class GetFeatureChannelListAction @Inject constructor(
*/
override fun doExecute(
task: Task?,
request: GetFeatureChannelListRequest,
request: ActionRequest,
listener: ActionListener<GetFeatureChannelListResponse>
) {
val transformedRequest = request as? GetFeatureChannelListRequest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
package org.opensearch.notifications.action

import org.opensearch.action.ActionListener
import org.opensearch.action.ActionRequest
import org.opensearch.action.support.ActionFilters
import org.opensearch.client.Client
import org.opensearch.common.inject.Inject
Expand Down Expand Up @@ -63,7 +64,7 @@ internal class GetNotificationConfigAction @Inject constructor(
*/
override fun doExecute(
task: Task?,
request: GetNotificationConfigRequest,
request: ActionRequest,
listener: ActionListener<GetNotificationConfigResponse>
) {
val transformedRequest = request as? GetNotificationConfigRequest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
package org.opensearch.notifications.action

import org.opensearch.action.ActionListener
import org.opensearch.action.ActionRequest
import org.opensearch.action.support.ActionFilters
import org.opensearch.client.Client
import org.opensearch.common.inject.Inject
Expand Down Expand Up @@ -63,7 +64,7 @@ internal class GetNotificationEventAction @Inject constructor(
*/
override fun doExecute(
task: Task?,
request: GetNotificationEventRequest,
request: ActionRequest,
listener: ActionListener<GetNotificationEventResponse>
) {
val transformedRequest = request as? GetNotificationEventRequest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
package org.opensearch.notifications.action

import org.opensearch.action.ActionListener
import org.opensearch.action.ActionRequest
import org.opensearch.action.support.ActionFilters
import org.opensearch.client.Client
import org.opensearch.common.inject.Inject
Expand Down Expand Up @@ -63,7 +64,7 @@ internal class GetPluginFeaturesAction @Inject constructor(
*/
override fun doExecute(
task: Task?,
request: GetPluginFeaturesRequest,
request: ActionRequest,
listener: ActionListener<GetPluginFeaturesResponse>
) {
val transformedRequest = request as? GetPluginFeaturesRequest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ internal abstract class PluginBaseAction<Request : ActionRequest, Response : Act
transportService: TransportService,
val client: Client,
actionFilters: ActionFilters,
requestReader: Writeable.Reader<Request>
) : HandledTransportAction<Request, Response>(name, transportService, actionFilters, requestReader) {
requestReader: Writeable.Reader<ActionRequest>
) : HandledTransportAction<ActionRequest, Response>(name, transportService, actionFilters, requestReader) {
companion object {
private val log by logger(PluginBaseAction::class.java)
private val scope: CoroutineScope = CoroutineScope(Dispatchers.IO)
Expand All @@ -66,18 +66,18 @@ internal abstract class PluginBaseAction<Request : ActionRequest, Response : Act
/**
* {@inheritDoc}
*/
@Suppress("TooGenericExceptionCaught")
@Suppress("TooGenericExceptionCaught", "UNCHECKED_CAST")
override fun doExecute(
task: Task?,
request: Request,
request: ActionRequest,
listener: ActionListener<Response>
) {
val userStr: String? =
client.threadPool().threadContext.getTransient<String>(OPENSEARCH_SECURITY_USER_INFO_THREAD_CONTEXT)
val user: User? = User.parse(userStr)
scope.launch {
try {
listener.onResponse(executeRequest(request, user))
listener.onResponse(executeRequest(request as Request, user))
} catch (exception: OpenSearchStatusException) {
log.warn("$LOG_PREFIX:OpenSearchStatusException:", exception)
listener.onFailure(exception)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
package org.opensearch.notifications.action

import org.opensearch.action.ActionListener
import org.opensearch.action.ActionRequest
import org.opensearch.action.support.ActionFilters
import org.opensearch.client.Client
import org.opensearch.common.inject.Inject
Expand Down Expand Up @@ -63,7 +64,7 @@ internal class SendNotificationAction @Inject constructor(
*/
override fun doExecute(
task: Task?,
request: SendNotificationRequest,
request: ActionRequest,
listener: ActionListener<SendNotificationResponse>
) {
val transformedRequest = request as? SendNotificationRequest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
package org.opensearch.notifications.action

import org.opensearch.action.ActionListener
import org.opensearch.action.ActionRequest
import org.opensearch.action.support.ActionFilters
import org.opensearch.client.Client
import org.opensearch.common.inject.Inject
Expand Down Expand Up @@ -63,7 +64,7 @@ internal class UpdateNotificationConfigAction @Inject constructor(
*/
override fun doExecute(
task: Task?,
request: UpdateNotificationConfigRequest,
request: ActionRequest,
listener: ActionListener<UpdateNotificationConfigResponse>
) {
val transformedRequest = request as? UpdateNotificationConfigRequest
Expand Down