mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
调整锁位置和 不必要的int拆箱
This commit is contained in:
parent
2fd1d5db70
commit
9dadfed42e
@ -144,8 +144,8 @@ public abstract class ReentrantCache<K, V> extends AbstractCache<K, V> {
|
||||
* @param withMissCount 是否计数丢失数
|
||||
*/
|
||||
private void remove(final K key, final boolean withMissCount) {
|
||||
lock.lock();
|
||||
CacheObj<K, V> co;
|
||||
lock.lock();
|
||||
try {
|
||||
co = removeWithoutLock(key, withMissCount);
|
||||
} finally {
|
||||
|
@ -365,7 +365,7 @@ public class Ipv4Util implements Ipv4Pool {
|
||||
* @return 掩码位,例如 24
|
||||
* @throws IllegalArgumentException 子网掩码非法
|
||||
*/
|
||||
public static int getMaskBitByMask(final String mask) {
|
||||
public static Integer getMaskBitByMask(final String mask) {
|
||||
final Integer maskBit = MaskBit.getMaskBit(mask);
|
||||
Assert.notNull(maskBit, "Invalid netmask:{}", mask);
|
||||
return maskBit;
|
||||
|
@ -302,9 +302,8 @@ public class SymmetricCrypto implements SymmetricEncryptor, SymmetricDecryptor,
|
||||
* @since 6.0.0
|
||||
*/
|
||||
public byte[] encrypt(final byte[] data, final byte[] salt) {
|
||||
lock.lock();
|
||||
|
||||
byte[] result;
|
||||
lock.lock();
|
||||
try {
|
||||
final Cipher cipher = initMode(Cipher.ENCRYPT_MODE, salt);
|
||||
result = cipher.doFinal(paddingDataWithZero(data, cipher.getBlockSize()));
|
||||
@ -318,9 +317,8 @@ public class SymmetricCrypto implements SymmetricEncryptor, SymmetricDecryptor,
|
||||
|
||||
@Override
|
||||
public void encrypt(final InputStream data, final OutputStream out, final boolean isClose) throws IORuntimeException {
|
||||
lock.lock();
|
||||
|
||||
CipherOutputStream cipherOutputStream = null;
|
||||
lock.lock();
|
||||
try {
|
||||
final Cipher cipher = initMode(Cipher.ENCRYPT_MODE, null);
|
||||
cipherOutputStream = new CipherOutputStream(out, cipher);
|
||||
@ -358,10 +356,9 @@ public class SymmetricCrypto implements SymmetricEncryptor, SymmetricDecryptor,
|
||||
public byte[] decrypt(final byte[] bytes) {
|
||||
final int blockSize;
|
||||
final byte[] decryptData;
|
||||
|
||||
lock.lock();
|
||||
final byte[] salt = SaltMagic.getSalt(bytes);
|
||||
try {
|
||||
final byte[] salt = SaltMagic.getSalt(bytes);
|
||||
final Cipher cipher = initMode(Cipher.DECRYPT_MODE, salt);
|
||||
blockSize = cipher.getBlockSize();
|
||||
decryptData = cipher.doFinal(SaltMagic.getData(bytes));
|
||||
@ -376,8 +373,8 @@ public class SymmetricCrypto implements SymmetricEncryptor, SymmetricDecryptor,
|
||||
|
||||
@Override
|
||||
public void decrypt(final InputStream data, final OutputStream out, final boolean isClose) throws IORuntimeException {
|
||||
lock.lock();
|
||||
CipherInputStream cipherInputStream = null;
|
||||
lock.lock();
|
||||
try {
|
||||
final Cipher cipher = initMode(Cipher.DECRYPT_MODE, null);
|
||||
cipherInputStream = new CipherInputStream(data, cipher);
|
||||
|
Loading…
x
Reference in New Issue
Block a user