From 4c711cede50d6f0876958827040d250fae9790c9 Mon Sep 17 00:00:00 2001 From: zhengjw22 Date: Tue, 12 Nov 2024 19:44:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=85=E7=90=86=E6=97=A0=E7=94=A8=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../smartboot/servlet/DefaultServlet.java | 9 +- .../tech/smartboot/servlet/util/LRUCache.java | 111 ------------------ 2 files changed, 1 insertion(+), 119 deletions(-) delete mode 100644 servlet-core/src/main/java/tech/smartboot/servlet/util/LRUCache.java diff --git a/servlet-core/src/main/java/tech/smartboot/servlet/DefaultServlet.java b/servlet-core/src/main/java/tech/smartboot/servlet/DefaultServlet.java index e79d5620..848d3be0 100644 --- a/servlet-core/src/main/java/tech/smartboot/servlet/DefaultServlet.java +++ b/servlet-core/src/main/java/tech/smartboot/servlet/DefaultServlet.java @@ -54,13 +54,6 @@ class DefaultServlet extends HttpServlet { private static final Logger LOGGER = LoggerFactory.getLogger(DefaultServlet.class); private static final int READ_BUFFER = 1024 * 1024; private static final String FAVICON_NAME = "favicon.ico"; - private static final String URL_404 = - "" + - "" + - "smart-http 404" + - "" + - "

smart-http 找不到你所请求的地址资源,404

" + - ""; private static byte[] faviconBytes = null; private final ThreadLocal sdf = new ThreadLocal() { @Override @@ -72,7 +65,7 @@ protected SimpleDateFormat initialValue() { * 默认页面 */ private long faviconModifyTime; - private DeploymentInfo deploymentInfo; + private final DeploymentInfo deploymentInfo; public DefaultServlet(DeploymentInfo deploymentInfo) { this.deploymentInfo = deploymentInfo; diff --git a/servlet-core/src/main/java/tech/smartboot/servlet/util/LRUCache.java b/servlet-core/src/main/java/tech/smartboot/servlet/util/LRUCache.java deleted file mode 100644 index f8662d7f..00000000 --- a/servlet-core/src/main/java/tech/smartboot/servlet/util/LRUCache.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (C) [2022] smartboot [zhengjunweimail@163.com] - * - * 企业用户未经smartboot组织特别许可,需遵循AGPL-3.0开源协议合理合法使用本项目。 - * - * Enterprise users are required to use this project reasonably - * and legally in accordance with the AGPL-3.0 open source agreement - * without special permission from the smartboot organization. - */ - -package tech.smartboot.servlet.util; - -import java.util.LinkedHashMap; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReentrantLock; - -/** - * @author 三刀 - * @version V1.0 , 2020/11/14 - */ -public class LRUCache extends LinkedHashMap { - - private static final float DEFAULT_LOAD_FACTOR = 0.75f; - - private static final int DEFAULT_MAX_CAPACITY = 1000; - private final Lock lock = new ReentrantLock(); - private volatile int maxCapacity; - - public LRUCache() { - this(DEFAULT_MAX_CAPACITY); - } - - public LRUCache(int maxCapacity) { - super(16, DEFAULT_LOAD_FACTOR, true); - this.maxCapacity = maxCapacity; - } - - @Override - protected boolean removeEldestEntry(java.util.Map.Entry eldest) { - return size() > maxCapacity; - } - - @Override - public boolean containsKey(Object key) { - try { - lock.lock(); - return super.containsKey(key); - } finally { - lock.unlock(); - } - } - - @Override - public V get(Object key) { - try { - lock.lock(); - return super.get(key); - } finally { - lock.unlock(); - } - } - - @Override - public V put(K key, V value) { - try { - lock.lock(); - return super.put(key, value); - } finally { - lock.unlock(); - } - } - - @Override - public V remove(Object key) { - try { - lock.lock(); - return super.remove(key); - } finally { - lock.unlock(); - } - } - - @Override - public int size() { - try { - lock.lock(); - return super.size(); - } finally { - lock.unlock(); - } - } - - @Override - public void clear() { - try { - lock.lock(); - super.clear(); - } finally { - lock.unlock(); - } - } - - public int getMaxCapacity() { - return maxCapacity; - } - - public void setMaxCapacity(int maxCapacity) { - this.maxCapacity = maxCapacity; - } - -} \ No newline at end of file