Comments (15)
It is funny because if I add
if(jsonRunner != null) {
jsonRunner.stop();
Thread.sleep(3000);
}
then it works. It seems like Netty takes some time to kill the threads.
from moco.
Could you please tell me which version you are using?
from moco.
The latest one the 0.9.1. For what I have seen it seems that the group of threads are not stopped immediately and synchronously because the server warns about the fact that some threads were created but not terminated.
from moco.
I have tried in another computer with the sleep to 3000 but the problem appears again:
SEVERE: The web application [/ba32e781-3a18-44b3-9547-7c26787f3fe7] appears to have started a thread named [pool-2-thread-1] but has failed to stop it. This is very likely to create a memory leak.
abr 08, 2014 10:29:06 AM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/ba32e781-3a18-44b3-9547-7c26787f3fe7] created a ThreadLocal with key of type [io.netty.util.internal.ThreadLocalRandom$2] (value [io.netty.util.internal.ThreadLocalRandom$2@77468cae]) and a value of type [io.netty.util.internal.ThreadLocalRandom] (value [io.netty.util.internal.ThreadLocalRandom@6cd3851]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
abr 08, 2014 10:29:06 AM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/ba32e781-3a18-44b3-9547-7c26787f3fe7] created a ThreadLocal with key of type [io.netty.util.Recycler$1] (value [io.netty.util.Recycler$1@93e33bd]) and a value of type [io.netty.util.Recycler.Stack] (value [io.netty.util.Recycler$Stack@464c47d9]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
abr 08, 2014 10:29:07 AM org.apache.openejb.arquillian.common.TomEEContainer undeploy
INFO: cleaning /var/folders/k7/5t5fmkj547315vzzv51wh0fh0000gn/T/arquillian-tomee-app-working-dir/0
abr 08, 2014 10:29:07 AM org.apache.catalina.core.StandardServer await
INFO: A valid shutdown command was received via the shutdown port. Stopping the Server instance.
abr 08, 2014 10:29:07 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-bio-49322"]
abr 08, 2014 10:29:07 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["ajp-bio-8009"]
abr 08, 2014 10:29:07 AM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Catalina
abr 08, 2014 10:29:07 AM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["http-bio-49322"]
abr 08, 2014 10:29:12 AM org.apache.tomcat.util.net.AbstractEndpoint shutdownExecutor
WARNING: The executor associated with thread pool [http-bio-49322] has not fully shutdown. Some application threads may still be running.
from moco.
BTW you can try it by yourself:
https://github.com/arquillian/arquillian-extension-moco
and the important class here is the https://github.com/arquillian/arquillian-extension-moco/blob/master/src/main/java/org/jboss/arquillian/moco/container/MocoLifecycleExecuter.java and the test https://github.com/arquillian/arquillian-extension-moco/blob/master/src/test/java/org/jboss/arquillian/moco/MocoExtensionTestCase.java
from moco.
It's Netty which didn't shutdown server as expected. I actually put a latency in the code from 0.9.1. Maybe I'll dig more.
from moco.
Ok I think it would be great to make some researching on this problem. I am thinking to open an issue to Netty people to see if they can address the problem because at least adding latency is only a patch not the real solution. Thank you so much.
from moco.
I have found a solution to this problem. I have read on Netty documentation that shutdownGracefully returns a Future class which means that you can synchronize and wait until threads are completely closed. So I have tried this modification on MocoServer class:
WARNING: it is not suitable for production code:
if (bossGroup != null) {
try {
bossGroup.shutdownGracefully().get();
} catch(InterruptedException e) {
} catch(ExecutionException e) {
}
bossGroup = null;
}
if (workerGroup != null) {
try {
workerGroup.shutdownGracefully().get();
workerGroup = null;
} catch(InterruptedException e) {
} catch(ExecutionException e) {
}
}
And now it works perfectly. Notice that I have added the get()
method. So if you agree I can send you a pull request with the modification.
BTW it would be awesome if I could have this issue fixed before 25th of April, do you think it will be possible to have a 0.9.2 version released before that date?
Thank you so much.
from moco.
It's really a good suggestion. In my current plan, the next release will in May 1st. I can publish snapshot version anytime. Can I know more about your release plan?
from moco.
Well my plan is to release this weekend the first alpha version of the extension (because there are some users that are waiting for start using it
In parallel of this on 25th of April I am going to talk in Barcelona JUG about Arquillian, NoMocks movement, Stubbs and so on and I would like to present Moco (and the extension) to all of them so I think that an snapshot version of Moco published would be awesome.
If you want I send you a pull request no problem, as you can see the change is really easy.
Thank you so much.
from moco.
Also I would like to use this issue to comment one issue I have found:
I am using next json file as expectation:
[
{
"request": {
"uri": "/currencies/exchange_rates"
},
"response": {
"json": {"foo":"bar"}
}
}
]
And I start Moco with next code:
List<InputStream> streams = new ArrayList<InputStream>();
streams.add(Resources.getResource(mocoFile).openStream());
jsonRunner = JsonRunner.newJsonRunnerWithStreams(
streams, of(port));
And next exception is thrown:
[http-bio-50884-exec-3] INFO Unrecognized field: Unrecognized field "json" (class com.github.dreamhead.moco.parser.model.ResponseSetting), not marked as ignorable (9 known properties: "headers", "path_resource", "text", "proxy", "cookies", "status", "version", "file", "latency"])
at [Source: sun.net.www.protocol.jar.JarURLConnection$JarURLInputStream@7df82b9f; line: 7, column: 19](through reference chain: com.github.dreamhead.moco.parser.model.SessionSetting["response"]->com.github.dreamhead.moco.parser.model.ResponseSetting["json"])
What I am doing wrong here? If instead of json type I add text then it works as expected.
Thank you so much.
from moco.
json api in json will be published in the next version. If you really want to use it, you can build Moco by yourself.
from moco.
Ok I have already done
Thank you so much for your help.
from moco.
Do you want I send you a pull request for shutting down Runner or you will implement it? I ask it to close this issue or attach a PR.
from moco.
It would be better if you can create PR with test cases for that.
from moco.
Related Issues (20)
- how to get different response for one api HOT 2
- When the response of a field value singular for Chinese characters, to return to the last character of the code
- 如何调整standalone的可接受大小 HOT 3
- 如何获取URI中的子串值作为返回报文 HOT 2
- moco怎么模拟入参为定长报文,出参同样返回定长报文 HOT 1
- maven run test with moco jsonHttpServer throw java.lang.RuntimeException: java.lang.IllegalArgumentException: unknown configuration :[Z@767df8bd HOT 1
- 怎么拿到请求中的remote_addr值?
- 部分中文和符号会出现乱码 HOT 3
- socket挡板当并发数较高时,出现了no buffer space available HOT 3
- default if json.req.prop not available HOT 1
- MOCO如何实现带参重定向 HOT 1
- socket请求实现多文件配置
- java.lang.IllegalArgumentException: unknown configuration
- Maven test fails to run moco server when using jacoco maven plugin 0.7.8 or newer #258
- Use URI path parameters on the response template HOT 6
- 返回值类型不支持xml HOT 2
- java.lang.IllegalArgumentException: unknown configuration :[Z@78073c4 HOT 2
- 请求参数中存在中文时,每次请求都报400,怎么进行解决? HOT 1
- 响应体中存在奇数个汉字的时候必定乱码 HOT 5
- 如何支持或的逻辑,以及如何支持对字段名采用正则匹配
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from moco.