mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
[performance-tests] remove writing attachment task from ProjectLoaded
leave only existing writeAttachmentToErrorDir as working solution GitOrigin-RevId: 2c6db94766d0adc26c1410c195bcf9800ec3e888
This commit is contained in:
committed by
intellij-monorepo-bot
parent
3d3c27aa89
commit
8368bb3f21
@@ -252,11 +252,6 @@ public final class ProjectLoaded extends InitProjectActivityJavaShim implements
|
||||
}
|
||||
|
||||
private static void writeAttachmentToErrorDir(Attachment attachment, Path path) {
|
||||
var executor = AppExecutorUtil.getAppScheduledExecutorService();
|
||||
var counter = new AtomicInteger(0);
|
||||
var isDone = new AtomicBoolean(false);
|
||||
|
||||
Path attachmentPath = Paths.get(attachment.getPath());
|
||||
try {
|
||||
Files.writeString(path, attachment.getDisplayText(), StandardOpenOption.APPEND, StandardOpenOption.CREATE);
|
||||
Files.writeString(path, System.lineSeparator(), StandardOpenOption.APPEND, StandardOpenOption.CREATE);
|
||||
@@ -264,44 +259,6 @@ public final class ProjectLoaded extends InitProjectActivityJavaShim implements
|
||||
catch (Exception e) {
|
||||
LOG.warn("Failed to write attachment `display text`", e);
|
||||
}
|
||||
|
||||
var task = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (isDone.get()) return;
|
||||
|
||||
try (FileChannel channel = FileChannel.open(attachmentPath, StandardOpenOption.READ)) {
|
||||
channel.lock();
|
||||
|
||||
int bufferSize = 1024;
|
||||
if (bufferSize > channel.size()) {
|
||||
bufferSize = (int)channel.size();
|
||||
}
|
||||
ByteBuffer buffer = ByteBuffer.allocate(bufferSize);
|
||||
|
||||
try (var writer = Files.newByteChannel(path)) {
|
||||
while (channel.read(buffer) > 0) {
|
||||
writer.write(buffer);
|
||||
buffer.clear();
|
||||
}
|
||||
}
|
||||
|
||||
isDone.set(true);
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.warn("Failed to store attachment", e);
|
||||
}
|
||||
finally {
|
||||
if (counter.getAndIncrement() >= 5) {
|
||||
LOG.warn(String.format("Unable to store attachment %s %s to path %s",
|
||||
attachment.getName(), attachment.getPath(), path.toString()));
|
||||
isDone.set(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
executor.scheduleWithFixedDelay(task, 0, 200, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user