Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exit the application when a panic occurs #1203

Merged
merged 5 commits into from
Sep 8, 2022

Conversation

chamil321
Copy link
Contributor

@chamil321 chamil321 commented Aug 23, 2022

Purpose

$subject and fixes ballerina-platform/ballerina-library#2714

Examples

import ballerina/http;

service / on new http:Listener(9090) {
    resource function 'default [string... ptt](http:Request req) {
        panic error http:ListenerError("This fails");
    }
}

Client :

curl -v http://localhost:9090/ptt
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 9090 (#0)
> GET /ptt HTTP/1.1
> Host: localhost:9090
> User-Agent: curl/7.64.1
> Accept: */*
> 
< HTTP/1.1 500 Internal Server Error
< content-type: text/plain
< content-length: 10
< server: ballerina
< date: Wed, 31 Aug 2022 10:26:23 +0530
< 
* Connection #0 to host localhost left intact
This fails* Closing connection 0

Server output :

error: This fails
        at chamil.foo.0.$anonType$_0:$default$**(main.bal:47)

Screenshot 2022-08-31 at 10 24 28

Checklist

  • Linked to an issue
  • Updated the changelog
  • [ ] Added tests - Cant have tests as the JVM exits
  • Updated the spec

@codecov
Copy link

codecov bot commented Sep 1, 2022

Codecov Report

Merging #1203 (7346641) into master (e25ef97) will increase coverage by 0.04%.
The diff coverage is 66.66%.

@@             Coverage Diff              @@
##             master    #1203      +/-   ##
============================================
+ Coverage     81.17%   81.22%   +0.04%     
  Complexity       71       71              
============================================
  Files           360      360              
  Lines         19382    19377       -5     
  Branches       4358     4359       +1     
============================================
+ Hits          15734    15739       +5     
+ Misses         2828     2819       -9     
+ Partials        820      819       -1     
Impacted Files Coverage Δ
ballerina/http_errors.bal 50.00% <ø> (ø)
...va/io/ballerina/stdlib/http/api/HttpConstants.java 100.00% <ø> (ø)
...rina/stdlib/http/api/HttpCallableUnitCallback.java 82.17% <33.33%> (-2.36%) ⬇️
ballerina/auth_desugar.bal 91.72% <100.00%> (ø)
...va/io/ballerina/stdlib/http/api/HttpErrorType.java 100.00% <100.00%> (ø)
.../http/api/HttpResponseInterceptorUnitCallback.java 89.74% <100.00%> (+0.08%) ⬆️
...ractimpl/sender/states/http2/RequestCompleted.java 68.00% <0.00%> (-12.00%) ⬇️
...mpl/sender/states/http2/WaitingFor100Continue.java 59.64% <0.00%> (-8.78%) ⬇️
...ctimpl/sender/states/http2/EntityBodyReceived.java 35.71% <0.00%> (-3.58%) ⬇️
...ontractimpl/listener/http2/Http2SourceHandler.java 88.88% <0.00%> (-2.78%) ⬇️
... and 10 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@chamil321 chamil321 requested a review from TharmiganK September 2, 2022 04:00
@chamil321 chamil321 merged commit 87d1867 into ballerina-platform:master Sep 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Panic inside a resource function does not kill the application
2 participants