From 0cd7f26c0d73eec320d88af1fa9888bccc9a59a9 Mon Sep 17 00:00:00 2001 From: zhou-hao Date: Thu, 30 Nov 2017 12:00:56 +0800 Subject: [PATCH] fix bugs --- .../oauth2/client/GrantType.java | 31 ----------------- .../oauth2/client/OAuth2Constants.java | 34 ------------------- .../oauth2/client/request/OAuth2Session.java | 2 +- .../simple/SimpleOAuth2SessionBuilder.java | 4 ++- .../session/AuthorizationCodeSession.java | 2 +- .../simple/session/DefaultOAuth2Session.java | 10 +++--- .../simple/session/PasswordSession.java | 2 +- .../web/oauth2/core/GrantType.java | 1 + .../web/oauth2/core/OAuth2Constants.java | 4 +-- .../dynamic/DynamicSqlSessionFactory.java | 2 +- .../dao/mybatis/utils/ResultMapsUtils.java | 6 +++- .../AbstractOAuth2CrudServiceTests.java | 12 +++---- .../datasource/service/DataSourceCache.java | 3 +- .../jta/AtomikosDataSourceConfig.java | 32 ++++++++--------- .../jta/JtaDynamicDataSourceService.java | 2 ++ .../oauth2/OAuth2SSOAuthorizingListener.java | 2 +- .../web/message/memory/MemoryMessager.java | 17 ++++------ .../authorization/UserController.java | 2 ++ .../web/entity/authorization/UserEntity.java | 4 +-- .../service/file/simple/LocalFileService.java | 23 +++++++------ 20 files changed, 66 insertions(+), 129 deletions(-) delete mode 100644 hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/GrantType.java delete mode 100644 hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/OAuth2Constants.java diff --git a/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/GrantType.java b/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/GrantType.java deleted file mode 100644 index 1a7467f91..000000000 --- a/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/GrantType.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2016 http://www.hswebframework.org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * - */ - -package org.hswebframework.web.authorization.oauth2.client; - -/** - * @author zhouhao - */ -public interface GrantType { - String authorization_code = "authorization_code"; - String implicit = "implicit"; - @SuppressWarnings("all") - String password = "password"; - String client_credentials = "client_credentials"; - String refresh_token = "refresh_token"; -} diff --git a/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/OAuth2Constants.java b/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/OAuth2Constants.java deleted file mode 100644 index d09b6217e..000000000 --- a/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/OAuth2Constants.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2016 http://www.hswebframework.org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * - */ - -package org.hswebframework.web.authorization.oauth2.client; - -/** - * @author zhouhao - */ -public interface OAuth2Constants { - String access_token = "access_token"; - String grant_type = "grant_type"; - String scope = "scope"; - String client_id = "client_id"; - String client_secret = "client_secret"; - String authorization = "Authorization"; - String redirect_uri = "redirect_uri"; - String response_type = "response_type"; - String state = "state"; -} diff --git a/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/request/OAuth2Session.java b/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/request/OAuth2Session.java index 9c83a7dad..e27c76b5a 100644 --- a/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/request/OAuth2Session.java +++ b/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/request/OAuth2Session.java @@ -30,7 +30,7 @@ import java.io.Serializable; * @see OAuth2Request * @since 3.0 */ -public interface OAuth2Session extends Serializable { +public interface OAuth2Session{ /** * 尝试进行认证 * diff --git a/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/SimpleOAuth2SessionBuilder.java b/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/SimpleOAuth2SessionBuilder.java index 0f9da18e8..0a6e7a456 100644 --- a/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/SimpleOAuth2SessionBuilder.java +++ b/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/SimpleOAuth2SessionBuilder.java @@ -25,6 +25,8 @@ import org.hswebframework.web.authorization.oauth2.client.simple.session.Authori import org.hswebframework.web.authorization.oauth2.client.simple.session.CachedOAuth2Session; import org.hswebframework.web.authorization.oauth2.client.simple.session.DefaultOAuth2Session; import org.hswebframework.web.authorization.oauth2.client.simple.session.PasswordSession; +import org.hswebframework.web.oauth2.core.GrantType; +import org.hswebframework.web.oauth2.core.OAuth2Constants; import java.util.List; import java.util.concurrent.locks.ReadWriteLock; @@ -110,7 +112,7 @@ public class SimpleOAuth2SessionBuilder implements OAuth2SessionBuilder { } - Supplier tokenGetter = () -> { + private Supplier tokenGetter = () -> { readWriteLock.readLock().lock(); try { return getClientCredentialsToken(); diff --git a/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/session/AuthorizationCodeSession.java b/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/session/AuthorizationCodeSession.java index cd8490432..8da2d8450 100644 --- a/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/session/AuthorizationCodeSession.java +++ b/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/session/AuthorizationCodeSession.java @@ -18,10 +18,10 @@ package org.hswebframework.web.authorization.oauth2.client.simple.session; -import org.hswebframework.web.authorization.oauth2.client.GrantType; import org.hswebframework.web.authorization.oauth2.client.OAuth2Constants; import org.hswebframework.web.authorization.oauth2.client.request.OAuth2Request; import org.hswebframework.web.authorization.oauth2.client.request.OAuth2Session; +import org.hswebframework.web.oauth2.core.GrantType; /** * @author zhouhao diff --git a/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/session/DefaultOAuth2Session.java b/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/session/DefaultOAuth2Session.java index fee7196ff..bf691bc58 100644 --- a/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/session/DefaultOAuth2Session.java +++ b/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/session/DefaultOAuth2Session.java @@ -24,13 +24,13 @@ import org.hswebframework.web.authorization.oauth2.client.request.OAuth2Request; import org.hswebframework.web.authorization.oauth2.client.request.OAuth2Session; import org.hswebframework.web.authorization.oauth2.client.response.OAuth2Response; import org.hswebframework.web.oauth2.core.ErrorType; +import org.hswebframework.web.oauth2.core.OAuth2Constants; import org.springframework.util.Assert; -import java.util.concurrent.locks.ReadWriteLock; -import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.function.Consumer; -import static org.hswebframework.web.authorization.oauth2.client.OAuth2Constants.*; +import static org.hswebframework.web.oauth2.core.OAuth2Constants.*; + /** * @author zhouhao @@ -165,8 +165,8 @@ public class DefaultOAuth2Session implements OAuth2Session { boolean[] skip = new boolean[1]; AccessTokenInfo tokenInfo = request .param(OAuth2Constants.scope, scope) - .param(OAuth2Constants.grant_type, GrantType.refresh_token) - .param(GrantType.refresh_token, accessTokenInfo.getRefreshToken()) + .param(OAuth2Constants.grant_type, org.hswebframework.web.oauth2.core.GrantType.refresh_token) + .param(org.hswebframework.web.oauth2.core.GrantType.refresh_token, accessTokenInfo.getRefreshToken()) .post().onError((oAuth2Response, type) -> { if(type== ErrorType.EXPIRED_REFRESH_TOKEN){ setAccessTokenInfo(requestAccessToken()); diff --git a/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/session/PasswordSession.java b/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/session/PasswordSession.java index c148ffa61..b7281225b 100644 --- a/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/session/PasswordSession.java +++ b/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/src/main/java/org/hswebframework/web/authorization/oauth2/client/simple/session/PasswordSession.java @@ -18,9 +18,9 @@ package org.hswebframework.web.authorization.oauth2.client.simple.session; -import org.hswebframework.web.authorization.oauth2.client.GrantType; import org.hswebframework.web.authorization.oauth2.client.OAuth2Constants; import org.hswebframework.web.authorization.oauth2.client.request.OAuth2Request; +import org.hswebframework.web.oauth2.core.GrantType; /** * @author zhouhao diff --git a/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-core/src/main/java/org/hswebframework/web/oauth2/core/GrantType.java b/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-core/src/main/java/org/hswebframework/web/oauth2/core/GrantType.java index d4e4b483b..29dbfb021 100644 --- a/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-core/src/main/java/org/hswebframework/web/oauth2/core/GrantType.java +++ b/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-core/src/main/java/org/hswebframework/web/oauth2/core/GrantType.java @@ -25,6 +25,7 @@ package org.hswebframework.web.oauth2.core; public interface GrantType { String authorization_code = "authorization_code"; String implicit = "implicit"; + @SuppressWarnings("all") String password = "password"; String client_credentials = "client_credentials"; String refresh_token = "refresh_token"; diff --git a/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-core/src/main/java/org/hswebframework/web/oauth2/core/OAuth2Constants.java b/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-core/src/main/java/org/hswebframework/web/oauth2/core/OAuth2Constants.java index 676a40f69..d0cea276f 100644 --- a/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-core/src/main/java/org/hswebframework/web/oauth2/core/OAuth2Constants.java +++ b/hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-core/src/main/java/org/hswebframework/web/oauth2/core/OAuth2Constants.java @@ -19,8 +19,6 @@ package org.hswebframework.web.oauth2.core; /** - * TODO 完成注释 - * * @author zhouhao */ public interface OAuth2Constants { @@ -36,6 +34,8 @@ public interface OAuth2Constants { String state = "state"; String code = "code"; String username = "username"; + + @SuppressWarnings("all") String password = "password"; } diff --git a/hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/src/main/java/org/hswebframework/web/dao/mybatis/dynamic/DynamicSqlSessionFactory.java b/hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/src/main/java/org/hswebframework/web/dao/mybatis/dynamic/DynamicSqlSessionFactory.java index 033bdeb41..bc39d360e 100644 --- a/hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/src/main/java/org/hswebframework/web/dao/mybatis/dynamic/DynamicSqlSessionFactory.java +++ b/hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/src/main/java/org/hswebframework/web/dao/mybatis/dynamic/DynamicSqlSessionFactory.java @@ -88,7 +88,7 @@ public class DynamicSqlSessionFactory implements SqlSessionFactory { return configuration; } - @SuppressWarnings("unchecked") + @SuppressWarnings("all") private SqlSession openSessionFromDataSource(ExecutorType execType, TransactionIsolationLevel level, boolean autoCommit) { Transaction tx = null; try { diff --git a/hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/src/main/java/org/hswebframework/web/dao/mybatis/utils/ResultMapsUtils.java b/hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/src/main/java/org/hswebframework/web/dao/mybatis/utils/ResultMapsUtils.java index 471f34987..5c1355022 100644 --- a/hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/src/main/java/org/hswebframework/web/dao/mybatis/utils/ResultMapsUtils.java +++ b/hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/src/main/java/org/hswebframework/web/dao/mybatis/utils/ResultMapsUtils.java @@ -37,9 +37,13 @@ public class ResultMapsUtils { try { countDownLatch.await(); } catch (InterruptedException e) { - throw new RuntimeException(e); + throw new UnsupportedOperationException(e); + } + if (sqlSession == null) { + throw new UnsupportedOperationException("sqlSession is null"); } } + return sqlSession.getConfiguration().getResultMap(id); } diff --git a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-oauth2/src/test/java/org/hswebframework/web/service/oauth2/AbstractOAuth2CrudServiceTests.java b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-oauth2/src/test/java/org/hswebframework/web/service/oauth2/AbstractOAuth2CrudServiceTests.java index 68b237fdd..3e97ddabb 100644 --- a/hsweb-commons/hsweb-commons-service/hsweb-commons-service-oauth2/src/test/java/org/hswebframework/web/service/oauth2/AbstractOAuth2CrudServiceTests.java +++ b/hsweb-commons/hsweb-commons-service/hsweb-commons-service-oauth2/src/test/java/org/hswebframework/web/service/oauth2/AbstractOAuth2CrudServiceTests.java @@ -55,23 +55,19 @@ public class AbstractOAuth2CrudServiceTests { createFixedResponseRequest( whenRequest("get", ResponseMessage.ok(entity)) , whenRequest("put", ResponseMessage.ok(1)) - , whenRequest("delete", ResponseMessage.ok(1))) - ); + , whenRequest("delete", ResponseMessage.ok(1)))); when(oAuth2Session.request("/test/all")).thenReturn( createFixedResponseRequest( - whenRequest("get", ResponseMessage.ok(Arrays.asList(entity))) - )); + whenRequest("get", ResponseMessage.ok(Arrays.asList(entity))))); when(oAuth2Session.request("/test/ids")).thenReturn( createFixedResponseRequest( - whenRequest("get", ResponseMessage.ok(Arrays.asList(entity))) - )); + whenRequest("get", ResponseMessage.ok(Arrays.asList(entity))))); when(oAuth2Session.request("/test/batch")).thenReturn( createFixedResponseRequest( - whenRequest("put", ResponseMessage.error(400, "名称不能为空")) - )); + whenRequest("put", ResponseMessage.error(400, "名称不能为空")))); when(sessionBuilder.byClientCredentials()).thenReturn(oAuth2Session); diff --git a/hsweb-datasource/hsweb-datasource-api/src/main/java/org/hswebframework/web/datasource/service/DataSourceCache.java b/hsweb-datasource/hsweb-datasource-api/src/main/java/org/hswebframework/web/datasource/service/DataSourceCache.java index 1e9efe382..ae0c42153 100644 --- a/hsweb-datasource/hsweb-datasource-api/src/main/java/org/hswebframework/web/datasource/service/DataSourceCache.java +++ b/hsweb-datasource/hsweb-datasource-api/src/main/java/org/hswebframework/web/datasource/service/DataSourceCache.java @@ -30,8 +30,9 @@ public class DataSourceCache { try { //等待初始化完成 initLatch.await(); - } catch (InterruptedException ignored) { + } catch (Exception ignored) { log.warn(ignored.getMessage(),ignored); + } finally { initLatch = null; } diff --git a/hsweb-datasource/hsweb-datasource-jta/src/main/java/org/hswebframework/web/datasource/jta/AtomikosDataSourceConfig.java b/hsweb-datasource/hsweb-datasource-jta/src/main/java/org/hswebframework/web/datasource/jta/AtomikosDataSourceConfig.java index 4cb5f5cbe..0c0f35a20 100644 --- a/hsweb-datasource/hsweb-datasource-jta/src/main/java/org/hswebframework/web/datasource/jta/AtomikosDataSourceConfig.java +++ b/hsweb-datasource/hsweb-datasource-jta/src/main/java/org/hswebframework/web/datasource/jta/AtomikosDataSourceConfig.java @@ -1,30 +1,30 @@ package org.hswebframework.web.datasource.jta; import com.atomikos.jdbc.AtomikosDataSourceBean; +import lombok.extern.slf4j.Slf4j; import java.sql.SQLException; import java.util.Properties; /** - * TODO 完成注释 - * * @author zhouhao */ +@Slf4j public class AtomikosDataSourceConfig { - private int minPoolSize = 5; - private int maxPoolSize = 200; - private int borrowConnectionTimeout = 60; - private int reapTimeout = 0; - private int maxIdleTime = 60; - private int maintenanceInterval = 60; - private int defaultIsolationLevel = -1; - private String xaDataSourceClassName = null; - private int loginTimeout = 0; - private String testQuery = null; - private int maxLifetime = 0; - private Properties xaProperties = null; + private int minPoolSize = 5; + private int maxPoolSize = 200; + private int borrowConnectionTimeout = 60; + private int reapTimeout = 0; + private int maxIdleTime = 60; + private int maintenanceInterval = 60; + private int defaultIsolationLevel = -1; + private String xaDataSourceClassName = null; + private int loginTimeout = 0; + private String testQuery = null; + private int maxLifetime = 0; + private Properties xaProperties = null; //初始化超时时间 - private int initTimeout = 10; + private int initTimeout = 10; @Override public int hashCode() { @@ -169,7 +169,7 @@ public class AtomikosDataSourceConfig { try { atomikosDataSourceBean.setLoginTimeout(getLoginTimeout()); } catch (SQLException e) { - e.printStackTrace(); + log.warn(e.getMessage(), e); } } atomikosDataSourceBean.setMaxIdleTime(getMaxIdleTime()); diff --git a/hsweb-datasource/hsweb-datasource-jta/src/main/java/org/hswebframework/web/datasource/jta/JtaDynamicDataSourceService.java b/hsweb-datasource/hsweb-datasource-jta/src/main/java/org/hswebframework/web/datasource/jta/JtaDynamicDataSourceService.java index 6bceec527..a1c693388 100644 --- a/hsweb-datasource/hsweb-datasource-jta/src/main/java/org/hswebframework/web/datasource/jta/JtaDynamicDataSourceService.java +++ b/hsweb-datasource/hsweb-datasource-jta/src/main/java/org/hswebframework/web/datasource/jta/JtaDynamicDataSourceService.java @@ -93,6 +93,7 @@ public class JtaDynamicDataSourceService extends AbstractDynamicDataSourceServic downLatch.countDown(); } catch (Exception e) { logger.error("init datasource {} error", id, e); + //atomikosDataSourceBean.close(); } }); @@ -102,6 +103,7 @@ public class JtaDynamicDataSourceService extends AbstractDynamicDataSourceServic Thread.sleep(config.getInitTimeout() * 1000L); } catch (InterruptedException ignored) { logger.warn(ignored.getMessage(), ignored); + Thread.currentThread().interrupt(); } finally { if (successCounter.get() == 0) { // 初始化超时,认定为失败 diff --git a/hsweb-examples/hsweb-examples-oauth2/hsweb-examples-oauth2-client/src/main/java/org/hswebframework/web/example/oauth2/OAuth2SSOAuthorizingListener.java b/hsweb-examples/hsweb-examples-oauth2/hsweb-examples-oauth2-client/src/main/java/org/hswebframework/web/example/oauth2/OAuth2SSOAuthorizingListener.java index fdb918064..9baa68847 100644 --- a/hsweb-examples/hsweb-examples-oauth2/hsweb-examples-oauth2-client/src/main/java/org/hswebframework/web/example/oauth2/OAuth2SSOAuthorizingListener.java +++ b/hsweb-examples/hsweb-examples-oauth2/hsweb-examples-oauth2-client/src/main/java/org/hswebframework/web/example/oauth2/OAuth2SSOAuthorizingListener.java @@ -73,7 +73,7 @@ public class OAuth2SSOAuthorizingListener HttpSession httpSession = WebUtil.getHttpServletRequest() .getSession(); - userTokenManager.signIn(httpSession.getId(), "sessionId",authentication.getUser().getId(), 60 * 60 * 1000); + userTokenManager.signIn(httpSession.getId(), "sessionId",authentication.getUser().getId(), 60 * 60 * 1000L); } diff --git a/hsweb-message/hsweb-message-memory/src/main/java/org/hswebframework/web/message/memory/MemoryMessager.java b/hsweb-message/hsweb-message-memory/src/main/java/org/hswebframework/web/message/memory/MemoryMessager.java index 18b923984..89e2127d2 100644 --- a/hsweb-message/hsweb-message-memory/src/main/java/org/hswebframework/web/message/memory/MemoryMessager.java +++ b/hsweb-message/hsweb-message-memory/src/main/java/org/hswebframework/web/message/memory/MemoryMessager.java @@ -15,7 +15,6 @@ import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.function.Consumer; /** - * * @author zhouhao */ @@ -82,21 +81,17 @@ public class MemoryMessager implements Messager { @Override public void cancel() { - boolean lockSuccess = true; try { queue.lock.writeLock().tryLock(5, TimeUnit.SECONDS); - } catch (InterruptedException e) { - lockSuccess = false; - log.warn(e.getMessage(),e); - } - try { - queue.consumers.remove(consumer); - } finally { try { + queue.consumers.remove(consumer); + } finally { queue.lock.writeLock().unlock(); - } catch (Exception e) { } + } catch (Exception e) { + log.warn(e.getMessage(), e); } + } }; } else if (subject instanceof TopicMessageSubject) { @@ -108,6 +103,6 @@ public class MemoryMessager implements Messager { class QueueConsumer { final List> consumers = new ArrayList<>(); - final ReadWriteLock lock = new ReentrantReadWriteLock(); + final ReadWriteLock lock = new ReentrantReadWriteLock(); } } diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-controller/src/main/java/org/hswebframework/web/controller/authorization/UserController.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-controller/src/main/java/org/hswebframework/web/controller/authorization/UserController.java index c34da4388..6e986b33a 100644 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-controller/src/main/java/org/hswebframework/web/controller/authorization/UserController.java +++ b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-controller/src/main/java/org/hswebframework/web/controller/authorization/UserController.java @@ -70,6 +70,7 @@ public class UserController implements } @Override + @SuppressWarnings("all") public ResponseMessage> list(QueryParamEntity param) { param.excludes("password", "salt"); return QueryController.super.list(param) @@ -77,6 +78,7 @@ public class UserController implements } @Override + @SuppressWarnings("all") public ResponseMessage getByPrimaryKey(@PathVariable String id) { return QueryController.super.getByPrimaryKey(id) .exclude(UserEntity.class, "password", "salt"); diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-entity/src/main/java/org/hswebframework/web/entity/authorization/UserEntity.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-entity/src/main/java/org/hswebframework/web/entity/authorization/UserEntity.java index c51d6de25..2b12341e3 100644 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-entity/src/main/java/org/hswebframework/web/entity/authorization/UserEntity.java +++ b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-entity/src/main/java/org/hswebframework/web/entity/authorization/UserEntity.java @@ -22,15 +22,13 @@ import org.hswebframework.web.commons.entity.GenericEntity; import org.hswebframework.web.commons.entity.RecordCreationEntity; /** - * TODO 完成注释 - * * @author zhouhao */ public interface UserEntity extends GenericEntity, RecordCreationEntity { String name = "name"; String username = "username"; String salt = "salt"; - @SuppressWarnings("unchecked") + @SuppressWarnings("all") String password = "password"; String status = "status"; diff --git a/hsweb-system/hsweb-system-file/hsweb-system-file-service/hsweb-system-file-service-simple/src/main/java/org/hswebframework/web/service/file/simple/LocalFileService.java b/hsweb-system/hsweb-system-file/hsweb-system-file-service/hsweb-system-file-service-simple/src/main/java/org/hswebframework/web/service/file/simple/LocalFileService.java index ba34a90b5..aae4a18a1 100644 --- a/hsweb-system/hsweb-system-file/hsweb-system-file-service/hsweb-system-file-service-simple/src/main/java/org/hswebframework/web/service/file/simple/LocalFileService.java +++ b/hsweb-system/hsweb-system-file/hsweb-system-file-service/hsweb-system-file-service-simple/src/main/java/org/hswebframework/web/service/file/simple/LocalFileService.java @@ -138,7 +138,7 @@ public class LocalFileService implements FileService { int fileSize; MessageDigest digest = DigestUtils.getMd5Digest(); - try (InputStream in =new InputStream() { + try (InputStream in = new InputStream() { @Override public int read(byte[] b, int off, int len) throws IOException { int l = fileStream.read(b, off, len); @@ -162,17 +162,17 @@ public class LocalFileService implements FileService { return fileStream.read(); } }; FileOutputStream os = new FileOutputStream(fileAbsName)) { - int remainBytes=fileSize= in.available(); - byte[] buff = new byte[remainBytes>1024*10?1024*10:remainBytes]; + int remainBytes = fileSize = in.available(); + byte[] buff = new byte[remainBytes > 1024 * 10 ? 1024 * 10 : remainBytes]; int bytes; - logger.info("开始写出文件:{}到:{}, size: {} bytes",fileName,fileAbsName,fileSize); + logger.info("开始写出文件:{}到:{}, size: {} bytes", fileName, fileAbsName, fileSize); while (remainBytes > 0) { - bytes = in.read(buff, 0, remainBytes > buff.length ? buff.length : remainBytes); + bytes = in.read(buff, 0, remainBytes > buff.length ? buff.length : remainBytes); os.write(buff, 0, bytes); remainBytes -= bytes; - logger.info("写出文件:{}:{},剩余数据量: {} bytes",fileName,fileAbsName, remainBytes); + logger.info("写出文件:{}:{},剩余数据量: {} bytes", fileName, fileAbsName, remainBytes); } - // StreamUtils.copy(in, os); + // StreamUtils.copy(in, os); } String md5 = Hex.encodeHexString(digest.digest()); @@ -182,7 +182,7 @@ public class LocalFileService implements FileService { //判断文件是否已经存在 FileInfoEntity fileInfo = fileInfoService.selectByMd5(md5); if (fileInfo != null) { - logger.info("文件:{}已上传过",fileAbsName); + logger.info("文件:{}已上传过", fileAbsName); if (new File(getFilePath() + "/" + fileInfo.getLocation()).exists()) { newFile.delete();//文件已存在则删除临时文件不做处理 } else { @@ -190,7 +190,7 @@ public class LocalFileService implements FileService { } return fileInfo; } else { - logger.info("上传文件{}完成:{}->{}",fileName,fileAbsName,absPath.concat("/").concat(md5)); + logger.info("上传文件{}完成:{}->{}", fileName, fileAbsName, absPath.concat("/").concat(md5)); newFile.renameTo(new File(absPath.concat("/").concat(md5))); } FileInfoEntity infoEntity = fileInfoService.createEntity(); @@ -199,7 +199,7 @@ public class LocalFileService implements FileService { infoEntity.setLocation(filePath.concat("/").concat(md5)); infoEntity.setName(fileName); infoEntity.setType(type); - infoEntity.setSize((long)fileSize); + infoEntity.setSize((long) fileSize); infoEntity.setMd5(md5); infoEntity.setStatus(DataStatus.STATUS_ENABLED); fileInfoService.insert(infoEntity); @@ -210,7 +210,8 @@ public class LocalFileService implements FileService { public void writeFile(String fileId, OutputStream out, long skip) throws IOException { try (InputStream inputStream = readFile(fileId)) { if (skip > 0) { - inputStream.skip(skip); + long len = inputStream.skip(skip); + logger.info("skip write stream {},{}", skip, len); } StreamUtils.copy(inputStream, out); }