Skip to content
Snippets Groups Projects
Commit 10c45b75 authored by Krzysztof Witukiewicz's avatar Krzysztof Witukiewicz
Browse files

Merge branch 'OZG-7426-DateitransferEingang' into 'main'

Ozg 7426 Fix NPE und OutOfMemory Exception

See merge request !13
parents 931c0268 2297585f
Branches
Tags
1 merge request!13Ozg 7426 Fix NPE und OutOfMemory Exception
......@@ -398,6 +398,8 @@
<env>
<BPE_DELIM_JAVA_TOOL_OPTIONS xml:space="preserve"> </BPE_DELIM_JAVA_TOOL_OPTIONS>
<BPE_APPEND_JAVA_TOOL_OPTIONS>-Dfile.encoding=UTF-8</BPE_APPEND_JAVA_TOOL_OPTIONS>
<BPE_APPEND_JAVA_TOOL_OPTIONS>-Dio.grpc.netty.shaded.io.netty.maxDirectMemory=0</BPE_APPEND_JAVA_TOOL_OPTIONS>
<BPE_APPEND_JAVA_TOOL_OPTIONS>-XX:MaxDirectMemorySize=512m</BPE_APPEND_JAVA_TOOL_OPTIONS>
<BPE_APPEND_LC_ALL>en_US.UTF-8</BPE_APPEND_LC_ALL>
</env>
</image>
......
......@@ -89,6 +89,9 @@ class OzgCloudFileRepository {
}
private long getContentSize(String contentId) {
if (Objects.isNull(contentId)) {
return 0;
}
var contentGridFsFile = gridFsTemplate.find(queryByObjectId(contentId)).first();
if (Objects.isNull(contentGridFsFile)) {
throw new NotFoundException(GridFSFile.class, contentId);
......
......@@ -100,6 +100,15 @@ class OzgCloudFileRepositoryITCase {
assertThat(result.getSize()).isEqualTo(OzgCloudFileTestFactory.SIZE);
}
@Test
void shouldSetContentSizeToZero() {
var ozgCloudFile = OzgCloudFileTestFactory.createBuilder().id(null).version(0).contentId(null).build();
var result = repository.save(ozgCloudFile);
assertThat(result.getSize()).isZero();
}
@Test
void shouldFailIfContentMissing() {
var ozgCloudFile = OzgCloudFileTestFactory.createBuilder().id(null).version(0).contentId("missing").build();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment