Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
5 changes: 3 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
"[yaml]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.formatOnSave": true
}
"editor.formatOnSave": true,
"java.configuration.updateBuildConfiguration": "interactive"
}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ and this project adheres to [Semantic Versioning].

- Initial stable pre-release version.
- Adds handling core CORS `Access-Control-Allow-Origins` header.
- Updated dependencies.
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ RUN apt-get update \
# Stage: builder
# -----------------------------------------------------------------------------
FROM ${IMAGE_BUILDER} AS builder
ENV REFRESHED_AT=2025-12-17
ENV REFRESHED_AT=2025-12-19
LABEL Name="senzing/java-builder" \
Maintainer="support@senzing.com" \
Version="0.4.0"
Expand Down Expand Up @@ -69,6 +69,7 @@ ENV PATH=${PATH}:${M2_HOME}/bin

# COPY ./rootfs /
COPY . /sz-sdk-java-grpc
#COPY --from=m2repo . /root/.m2/repository

# Set path to Senzing libs.

Expand All @@ -89,7 +90,7 @@ RUN mvn -ntp -DskipTests=true package
# -----------------------------------------------------------------------------

FROM ${IMAGE_FINAL} AS final
ENV REFRESHED_AT=2025-12-17
ENV REFRESHED_AT=2025-12-19
LABEL Name="senzing/sz-sdk-grpc-java" \
Maintainer="support@senzing.com" \
Version="0.4.0"
Expand Down
2 changes: 1 addition & 1 deletion checkstyle-suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
<suppress checks="ParameterNumber" files="."/>
<suppress checks="MagicNumber" files="."/>
<suppress checks="AvoidNestedBlocks" files="."/>
<suppress checks="MethodLength" files="src/main/java/com/senzing/sdk/grpc/server/SzGrpcServerOption.java"/>
<suppress checks="MethodLength" files="."/>
<suppress checks=".*" files="target/generated-sources/protobuf/.*"/>
</suppressions>
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
<dependency>
<groupId>com.senzing</groupId>
<artifactId>data-mart-replicator</artifactId>
<version>2.0.0-beta.1.2</version>
<version>2.0.0-beta.1.3</version>
</dependency>
<dependency>
<groupId>com.senzing</groupId>
Expand Down
50 changes: 27 additions & 23 deletions src/main/java/com/senzing/sdk/grpc/server/SzGrpcServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -422,21 +422,12 @@ protected SzGrpcServer(SzEnvironment env,
}
}

// build the GRPC service
GrpcService grpcService = GrpcService.builder()
.useBlockingTaskExecutor(true)
.addService(new SzGrpcProductImpl(this))
.addService(new SzGrpcConfigImpl(this))
.addService(new SzGrpcConfigManagerImpl(this))
.addService(new SzGrpcDiagnosticImpl(this))
.addService(new SzGrpcEngineImpl(this))
.build();

// create the server builder
ServerBuilder serverBuilder = Server.builder()
.http(new InetSocketAddress(bindAddress, port))
.blockingTaskExecutor(concurrency);

// create a CORS decorator if we need to decorate the server
// NOTE: we decorate the ENTIRE server rather than the GrpcService or
// AnnotatedService individually, because redirects (especially regarding
// paths ending "/") can lead to one path supporting CORS while the other
// does not. By using the decorator on the whole server, then all paths
// support CORS.
Function<? super HttpService, ? extends HttpService> corsDecorator = null;

List<String> allowedOrigins = options.getAllowedOrigins();
Expand All @@ -445,21 +436,39 @@ protected SzGrpcServer(SzEnvironment env,
corsDecorator = CorsService.builderForAnyOrigin()
.allowRequestMethods(GET, HEAD, POST, PUT, DELETE, OPTIONS)
.allowAllRequestHeaders(true)
.exposeHeaders("*")
.maxAge(3600)
.newDecorator();
} else {
corsDecorator = CorsService.builder(allowedOrigins)
.allowRequestMethods(GET, HEAD, POST, PUT, DELETE, OPTIONS)
.allowAllRequestHeaders(true)
.allowCredentials()
.exposeHeaders("*")
.maxAge(3600)
.newDecorator();
}
}

// build the GRPC service
GrpcService grpcService = GrpcService.builder()
.useBlockingTaskExecutor(true)
.addService(new SzGrpcProductImpl(this))
.addService(new SzGrpcConfigImpl(this))
.addService(new SzGrpcConfigManagerImpl(this))
.addService(new SzGrpcDiagnosticImpl(this))
.addService(new SzGrpcEngineImpl(this))
.build();

// create the server builder
ServerBuilder serverBuilder = Server.builder()
.http(new InetSocketAddress(bindAddress, port))
.blockingTaskExecutor(concurrency)
.service(grpcService);

// decorate the GRPC service with the CORS decorator if we have one
if (corsDecorator != null) {
serverBuilder.service(grpcService, corsDecorator);
} else {
serverBuilder.service(grpcService);
serverBuilder.decoratorUnder("/", corsDecorator);
}

// check if we need to build with data mart services
Expand All @@ -479,11 +488,6 @@ protected SzGrpcServer(SzEnvironment env,
.responseConverters(
new JacksonResponseConverterFunction(this.objectMapper));

// conditionally decorate for CORS
if (corsDecorator != null) {
builder.decorator(corsDecorator);
}

// now build the annotated service and bind it to the server builder
builder.build(dataMartReports);
}
Expand Down
Loading