fix: incorrect truncation of CSS resource reads (#4678)

#### What type of PR is this?
/kind bug
/area core
/milestone 2.10.x

#### What this PR does / why we need it:
修复插件 css bundle 内容被错误拆分导致无法加载的问题

#### Which issue(s) this PR fixes:
Fixes #4677

#### Does this PR introduce a user-facing change?
```release-note
修复插件 css bundle 内容被错误拆分导致无法加载的问题
```
pull/4688/head^2
guqing 2023-10-07 18:42:45 +08:00 committed by GitHub
parent 40565f1f32
commit d443c3ed29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 4 deletions

View File

@ -26,7 +26,6 @@ import org.springframework.core.io.buffer.DefaultDataBufferFactory;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
import org.springframework.util.StreamUtils;
import org.springframework.web.server.ServerWebInputException;
import reactor.core.Exceptions;
import reactor.core.publisher.Flux;
@ -179,9 +178,15 @@ public class PluginServiceImpl implements PluginService {
return BundleResourceUtils.getJsBundleResource(pluginManager, pluginName,
BundleResourceUtils.CSS_BUNDLE);
})
.flatMap(resource -> DataBufferUtils.read(resource,
DefaultDataBufferFactory.sharedInstance, StreamUtils.BUFFER_SIZE)
);
.flatMap(resource -> {
try {
return DataBufferUtils.read(resource, DefaultDataBufferFactory.sharedInstance,
(int) resource.contentLength());
} catch (IOException e) {
log.error("Failed to read plugin css bundle resource", e);
return Flux.empty();
}
});
}
@Override