我有以下几行代码:
NSURL *url = [NSURL URLWithString:URL];
NSURLRequest* request = [NSURLRequest requestWithURL:url .... ];
NSURLConnection* connection = [NSURLConnection alloc];
[connection initWithRequest:request delegate:self];
Run Code Online (Sandbox Code Playgroud)
在最后一行,我得到"表达结果未使用"警告.现在,根据我在网上阅读的所有文章,这是调用方法的正确方法,建议语法下载URL异步.如何重写此代码以修复警告?
自 2019 年 8 月 21 日起可用的声纳规则 ( squid:S5164 / RSPEC-5164 ) 要求在不再使用时清理“ThreadLocal”变量。因此,让我们学习以下类(兼容 JDK6):
public class ThreadLocalExample {
private static final ThreadLocal<NumberFormat> formats = new ThreadLocal<NumberFormat>() {
@Override
protected NumberFormat initialValue() {
final NumberFormat nf = NumberFormat.getNumberInstance(Locale.US);
nf.setMinimumFractionDigits(2);
nf.setMaximumFractionDigits(2);
nf.setGroupingUsed(false);
return nf;
}
};
public static NumberFormat getFormatter() {
return formats.get();
}
}
Run Code Online (Sandbox Code Playgroud)
声纳报告一个重要的错误的ThreadLocal声明,在以下的说明:
不再使用时应清除“ThreadLocal”变量
ThreadLocal一旦持有线程不再活动,变量应该被垃圾收集。重新使用持有线程时可能会发生内存泄漏,使用线程池的应用程序服务器就是这种情况。为避免此类问题,建议始终
ThreadLocal使用remove()清除当前线程的ThreadLocal变量值的方法清理 变量。
现在,我采用这种ThreadLocal方法是为了NumberFormat尽可能多地重用实例,避免每次调用创建一个实例,所以我认为如果我remove()在代码中的某个地方调用,我将失去这个解决方案的所有优点。我错过了什么吗?非常感谢。
早上好,
我用Innosetup创建的exe被视为病毒!!!
真的很烦,因为我无法发送给他们帮助。有人遇到过这个问题吗?
我使用的是InnoSetup 5.5,我实际上并没有复制文件,我只需要生成一些命令即可处理证书。
提前致谢
[编辑]
Inno脚本
因此,这有点复杂,因为我需要使用psexec进行管理,删除先前的证书,然后安装新的证书。
#define MyAppName "Update Certificate"
#define MyAppVersion "1.0"
#define MyAppPublisher "kkk"
#define MyAppExeName "updateBase"
#define installConf "installConfig.exe"
#define uninstallCert "unCert.exe"
#define psexec "psexec.exe"
#define passAdmin "password"
[Setup]
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppPublisher={#MyAppPublisher}
DefaultDirName={localappdata}
DisableDirPage=yes
DisableReadyPage=yes
DisableWelcomePage=yes
PrivilegesRequired=none
CreateAppDir=no
CreateUninstallRegKey = no
OutputBaseFilename={#MyAppExeName}
Compression=lzma
SolidCompression=yes
SetupIconFile=favicon.ico
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Files]
Source: "{#installConf}"; Flags: dontcopy
Source: "{#psexec}"; Flags: dontcopy
Source: "{#uninstallCert}"; Flags: dontcopy
[Code]
var
ResultCode: Integer;
Page: TWizardPage;
CustomPageID: Integer;
InstallRadioButton: TNewRadioButton;
DeleteRadioButton: …Run Code Online (Sandbox Code Playgroud) 我正在使用Inno Setup为 Windows 打包 Java 应用程序;应用程序树是这样的:
| MyApp.jar
\---lib
| dependency-A-1.2.3.jar
| dependency-B-2.3.4.jar
| dependency-Z-x.y.z.jar
Run Code Online (Sandbox Code Playgroud)
我使用Ant预先准备整个树(所有文件和文件夹),包括lib目录(使用*.jar通配符复制依赖项),然后我只需调用ISCC:
[Files]
Source: "PreparedFolder\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs
Run Code Online (Sandbox Code Playgroud)
现在,每次用户升级应用程序时我都需要清理lib目录,因为我想删除任何过时的依赖项。我可以将以下部分添加到我的.iss文件中:
[InstallDelete]
{app}\lib\*.jar
Run Code Online (Sandbox Code Playgroud)
但我觉得不安全,因为如果用户决定将应用程序安装在包含非空文件夹的现有文件夹中 lib文件夹(罕见但并非不可能),则升级时可能会删除某些用户文件。
是否有一些最佳实践可以避免这种麻烦?其他安装人员是否会解决这些令人头疼的问题?谢谢。
inno-setup ×2
java ×2
exe ×1
installation ×1
ios ×1
jar ×1
memory-leaks ×1
objective-c ×1
sonarqube ×1
thread-local ×1
upgrade ×1
virus ×1