SpringBoot异步调用方法遇到的问题
2021-01-03 10:29
标签:inner back str read com util 启动 span track 启动类加@EnableAsync注解开启异步调用方法功能 在加@Async注解的异步方法里面调用如下代码上传神策数据 报错信息如下: 源码分析: 在如下代码处抛出异常信息“fail to write file.” 此问题不知是什么原因??????? SpringBoot异步调用方法遇到的问题 标签:inner back str read com util 启动 span track 原文地址:https://www.cnblogs.com/it-deepinmind/p/12991603.html public void track(String distinctId,String eventName,Map
java.lang.RuntimeException: fail to write file.
at com.sensorsdata.analytics.javasdk.SensorsAnalytics$ConcurrentLoggingConsumer$InnerLoggingFileWriter.write(SensorsAnalytics.java:577) ~[SensorsAnalyticsSDK-3.1.15.jar:?]
at com.sensorsdata.analytics.javasdk.SensorsAnalytics$InnerLoggingConsumer.flush(SensorsAnalytics.java:680) ~[SensorsAnalyticsSDK-3.1.15.jar:?]
at com.sensorsdata.analytics.javasdk.SensorsAnalytics$ConcurrentLoggingConsumer.flush(SensorsAnalytics.java:463) ~[SensorsAnalyticsSDK-3.1.15.jar:?]
at com.sensorsdata.analytics.javasdk.SensorsAnalytics$InnerLoggingConsumer.close(SensorsAnalytics.java:686) ~[SensorsAnalyticsSDK-3.1.15.jar:?]
at com.sensorsdata.analytics.javasdk.SensorsAnalytics$ConcurrentLoggingConsumer.close(SensorsAnalytics.java:463) ~[SensorsAnalyticsSDK-3.1.15.jar:?]
at com.sensorsdata.analytics.javasdk.SensorsAnalytics.shutdown(SensorsAnalytics.java:1035) ~[SensorsAnalyticsSDK-3.1.15.jar:?]
at com.huixiaoer.base.service.impl.SensorsAnalyticsServiceImpl.track(SensorsAnalyticsServiceImpl.java:194) ~[classes/:?]
at com.huixiaoer.base.service.impl.SensorsAnalyticsServiceImpl.bookingSucceed(SensorsAnalyticsServiceImpl.java:135) ~[classes/:?]
at com.huixiaoer.base.service.impl.SensorsAnalyticsServiceImpl.sensorsAnalyticsBookingSucceed(SensorsAnalyticsServiceImpl.java:114) ~[classes/:?]
at com.huixiaoer.base.service.impl.SensorsAnalyticsServiceImpl$$FastClassBySpringCGLIB$$c8dce33d.invoke(
public boolean write(StringBuilder sb) {
synchronized(this.lockStream) {
FileLock lock = null;
try {
FileChannel channel = this.lockStream.getChannel();
lock = channel.lock(0L, 9223372036854775807L, false);
this.outputStream.write(sb.toString().getBytes("UTF-8"));
} catch (Exception var14) {
throw new RuntimeException("fail to write file.", var14);
} finally {
if (lock != null) {
try {
lock.release();
} catch (IOException var13) {
throw new RuntimeException("fail to release file lock.", var13);
}
}
}
return true;
}
}
!this.isOpen()为true,导致var20为null,(FileLock)var20异常,最后走finally代码块结束。
public FileLock lock(long var1, long var3, boolean var5) throws IOException {
this.ensureOpen();
if (var5 && !this.readable) {
throw new NonReadableChannelException();
} else if (!var5 && !this.writable) {
throw new NonWritableChannelException();
} else {
FileLockImpl var6 = new FileLockImpl(this, var1, var3, var5);
FileLockTable var7 = this.fileLockTable();
var7.add(var6);
boolean var8 = false;
int var9 = -1;
try {
this.begin();
var9 = this.threads.add();
if (!this.isOpen()) {
Object var20 = null;
return (FileLock)var20;
}
int var10;
do {
var10 = this.nd.lock(this.fd, true, var1, var3, var5);
} while(var10 == 2 && this.isOpen());
if (this.isOpen()) {
if (var10 == 1) {
assert var5;
FileLockImpl var11 = new FileLockImpl(this, var1, var3, false);
var7.replace(var6, var11);
var6 = var11;
}
var8 = true;
}
} finally {
if (!var8) {
var7.remove(var6);
}
this.threads.remove(var9);
try {
this.end(var8);
} catch (ClosedByInterruptException var18) {
throw new FileLockInterruptionException();
}
}
return var6;
}
}
上一篇:java内部类
下一篇:java 文件流 输入流 输出流
文章标题:SpringBoot异步调用方法遇到的问题
文章链接:http://soscw.com/index.php/essay/39798.html