Skip to content

Commit f03de62

Browse files
committed
1 parent 0fab0ed commit f03de62

6 files changed

Lines changed: 50 additions & 34 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# ActFramework Change Log
22

33
**1.8.6**
4+
* built_in_req_handler.enabled` configuration issue #590
5+
* It does not print warning message for app without secret configured #592
46
* API Doc - failed to generate sample data for List typed embedded data structure #591
57
* API Doc - make it able to hide system endpoints #589
68
* API doc - set maximum length for the description width #588

src/main/java/act/app/App.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
* #L%
2121
*/
2222

23+
import static act.app.event.SysEventId.*;
24+
import static org.osgl.http.H.Method.GET;
25+
2326
import act.Act;
2427
import act.Destroyable;
2528
import act.apidoc.ApiManager;
@@ -93,15 +96,12 @@
9396
import org.rythmengine.utils.I18N;
9497
import osgl.version.Version;
9598

96-
import javax.enterprise.context.ApplicationScoped;
97-
import javax.inject.Singleton;
9899
import java.io.File;
99100
import java.io.IOException;
100101
import java.lang.annotation.Annotation;
101102
import java.util.*;
102-
103-
import static act.app.event.SysEventId.*;
104-
import static org.osgl.http.H.Method.GET;
103+
import javax.enterprise.context.ApplicationScoped;
104+
import javax.inject.Singleton;
105105

106106
/**
107107
* {@code App} represents an application that is deployed in a Act container
@@ -1370,9 +1370,6 @@ private void loadRoutes() {
13701370
}
13711371

13721372
private void loadBuiltInRoutes() {
1373-
if (!config().builtInReqHandlerEnabled()) {
1374-
return;
1375-
}
13761373
router().addMapping(GET, "/asset/", new ResourceGetter("asset"), RouteSource.BUILD_IN);
13771374
router().addMapping(GET, "/~/asset/", new ResourceGetter("asset/~act"), RouteSource.BUILD_IN);
13781375
router().addMapping(GET, "/webjars/", new ResourceGetter("META-INF/resources/webjars"), RouteSource.BUILD_IN);

src/main/java/act/conf/AppConfig.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public void preloadConfigurations() {
150150
MvcConfig.jsonMediaTypeProvider(jsonContentProvider);
151151
}
152152

153-
OsglConfig.setThreadLocalBufferLimit(strBufRetentionLimit());
153+
OsglConfig.setThreadLocalBufferLimit(threadLocalBufRetentionLimit());
154154
}
155155

156156
public App app() {
@@ -1569,21 +1569,21 @@ private void _mergeAjaxCsrfCheckFailureHandler(AppConfig config) {
15691569
}
15701570
}
15711571

1572-
private Integer strBufRetentionLimit;
1573-
protected T strBufRetentionLimit(int limit) {
1574-
strBufRetentionLimit = limit;
1572+
private Integer threadlocalBufRetentionLimit;
1573+
protected T threadLocalBufRetentionLimit(int limit) {
1574+
threadlocalBufRetentionLimit = limit;
15751575
return me();
15761576
}
1577-
public int strBufRetentionLimit() {
1578-
if (null == strBufRetentionLimit) {
1577+
public int threadLocalBufRetentionLimit() {
1578+
if (null == threadlocalBufRetentionLimit) {
15791579
StrBufRetentionLimitCalculator calc = new StrBufRetentionLimitCalculator();
1580-
strBufRetentionLimit = get(OSGL_STRBUF_RETENTION_LIMIT, 1024 * calc.calculate());
1580+
threadlocalBufRetentionLimit = get(OSGL_THREADLOCAL_BUF_LIMIT, 1024 * calc.calculate());
15811581
}
1582-
return strBufRetentionLimit;
1582+
return threadlocalBufRetentionLimit;
15831583
}
15841584
private void _mergeStrBufRetentionLimit(AppConfig config) {
1585-
if (!hasConfiguration(OSGL_STRBUF_RETENTION_LIMIT)) {
1586-
strBufRetentionLimit = config.strBufRetentionLimit;
1585+
if (!hasConfiguration(OSGL_THREADLOCAL_BUF_LIMIT)) {
1586+
threadlocalBufRetentionLimit = config.threadlocalBufRetentionLimit;
15871587
}
15881588
}
15891589

@@ -2348,7 +2348,7 @@ protected T secret(String secret) {
23482348
public String secret() {
23492349
if (null == secret) {
23502350
secret = get(AppConfigKey.SECRET, "myawesomeapp");
2351-
if ("myawsomeapp".equals(secret)) {
2351+
if ("myawesomeapp".equals(secret)) {
23522352
logger.warn("Application secret key not set! You are in the dangerous zone!!!");
23532353
}
23542354
}

src/main/java/act/conf/AppConfigKey.java

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ public enum AppConfigKey implements ConfigKey {
273273
CORS_HEADERS_EXPOSE("cors.headers.expose"),
274274

275275
/**
276-
* {@code act.cors.headers.expose} specify `Access-Control-Allow-Headers`.
276+
* {@code act.cors.headers.allowed} specify `Access-Control-Allow-Headers`.
277277
* Note this setting will overwrite the setting of {@link #CORS_HEADERS} if
278278
* it is set
279279
*
@@ -299,8 +299,8 @@ public enum AppConfigKey implements ConfigKey {
299299
* {@code act.content_suffix.aware.enabled}
300300
* <p>
301301
* Once enabled then the framework automatically recognize request with content suffix.
302-
* E.g. {@code /customer/123/json} or {@code /customer/123.json} will match the
303-
* route {@code /customer/123} and set the request {@code Accept} header to
302+
* E.g. {@code /customer/123/json} will match the route {@code /customer/123}
303+
* and set the request {@code Accept} header to
304304
* {@code application/json}
305305
* </p>
306306
* <p>Default value: {@code false}</p>
@@ -445,6 +445,8 @@ public enum AppConfigKey implements ConfigKey {
445445
* implements {@link UnknownHttpMethodProcessor} that process
446446
* the HTTP methods that are not recognized by {@link act.route.Router},
447447
* e.g. "OPTION", "PATCH" etc
448+
*
449+
* Default value: {@link UnknownHttpMethodProcessor#METHOD_NOT_ALLOWED}
448450
*/
449451
HANDLER_UNKNOWN_HTTP_METHOD("handler.unknown_http_method.impl"),
450452

@@ -584,7 +586,8 @@ public enum AppConfigKey implements ConfigKey {
584586
/**
585587
* {@code act.idgen.seq_id.provider.impl} specifies the {@link act.util.IdGenerator.SequenceProvider}
586588
* implementation for {@link App#idGenerator}
587-
* <p>Default value: {@link act.util.IdGenerator.SequenceProvider.AtomicLongSeq}</p>
589+
*
590+
* Default value: {@link act.util.IdGenerator.SequenceProvider.AtomicLongSeq}
588591
*/
589592
ID_GEN_SEQ_ID_PROVIDER("idgen.seq_id.provider.impl"),
590593

@@ -678,24 +681,28 @@ public <T> T val(Map<String, ?> configuration) {
678681
* {@code act.namedPorts} specifies a list of port names this
679682
* application listen to. These are additional ports other than
680683
* the default {@link #HTTP_PORT}
681-
* <p/>
684+
*
682685
* The list is specified as
683-
* <pre><code>
686+
*
687+
* ```
684688
* act.namedPorts=admin:8888;ipc:8899
685-
* </code></pre>
686-
* <p>Default value: {@code null}</p>
687-
* <p>Note, the default port that specified in {@link #HTTP_PORT} configuration
688-
* and shall not be specified in this namedPorts configuration</p>
689+
* ```
690+
*
691+
* Default value: `null`
692+
*
693+
* Note, the default port that specified in {@link #HTTP_PORT} configuration
694+
* and shall not be specified in this namedPorts configuration
689695
*/
690696
NAMED_PORTS("namedPorts"),
691697

692698
/**
693-
* `strbuf.retention.limit` set the maximum size of threadlocal instance
694-
* of {@link S.Buffer} before it get dropped.
699+
* `threadlocal_buf.limit` set the maximum size of thread local instance
700+
* of {@link S.Buffer} and {@link org.osgl.util.ByteArrayBuffer} before it
701+
* get dropped.
695702
*
696703
* Default value: 1024 * 8 (i.e. 8k)
697704
*/
698-
OSGL_STRBUF_RETENTION_LIMIT("strbuf.retention.limit"),
705+
OSGL_THREADLOCAL_BUF_LIMIT("threadlocal_buf.limit"),
699706

700707
/**
701708
* `password.spec` specify default password spec which is used to
@@ -789,7 +796,7 @@ public <T> T val(Map<String, ?> configuration) {
789796

790797
/**
791798
* {@code resolver.template_path.impl} specifies the class that
792-
* implements {@link TemplatePathResolver}. Application
799+
* extends {@link TemplatePathResolver}. Application
793800
* developer could use this configuration to add some flexibility to
794801
* template path resolving logic, e.g. different home for different locale
795802
* or different home for different device type etc.

src/main/java/act/route/Router.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,16 @@ public void addMapping(final H.Method method, final CharSequence path, RequestHa
310310
if (isTraceEnabled()) {
311311
trace("R+ %s %s | %s (%s)", method, path, handler, source);
312312
}
313+
if (!app().config().builtInReqHandlerEnabled()) {
314+
String sPath = path.toString();
315+
if (sPath.startsWith("/~/")) {
316+
// disable built-in handlers except those might impact application behaviour
317+
// apibook is allowed here as it only available on dev mode
318+
if (!(sPath.contains("asset") || sPath.contains("i18n") || sPath.contains("job") || sPath.contains("api") || sPath.contains("ticket"))) {
319+
return;
320+
}
321+
}
322+
}
313323
Node node = _locate(method, path, handler.toString());
314324
if (null == node.handler) {
315325
Set<Node> conflicts = node.conflicts();

src/main/java/act/util/ActContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ protected Base(App app, boolean noLogger) {
291291
attributes = new HashMap<>();
292292
listenerList = new ArrayList<>();
293293
destroyableList = new ArrayList<>();
294-
strBuf = S.newSizedBuffer(app.config().strBufRetentionLimit());
294+
strBuf = S.newSizedBuffer(app.config().threadLocalBufRetentionLimit());
295295
violations = new HashMap<>();
296296
}
297297

0 commit comments

Comments
 (0)