Skip to content

Commit 5ec61dd

Browse files
authored
tcp + fix exception in CREATE DATA (#939)
1 parent 2afdc6e commit 5ec61dd

5 files changed

+42
-8
lines changed

Diff for: package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
"@abaplint/cli": "^2.113.108",
1919
"@abaplint/database-pg": "^2.10.24",
2020
"@abaplint/database-sqlite": "^2.10.24",
21-
"@abaplint/runtime": "^2.10.34",
22-
"@abaplint/transpiler-cli": "^2.10.34",
21+
"@abaplint/runtime": "^2.10.37",
22+
"@abaplint/transpiler-cli": "^2.10.37",
2323
"0x": "^5.8.0"
2424
}
2525
}

Diff for: src/kernel/kernel_create_data_handle.clas.abap

+3-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ ENDCLASS.
3131
CLASS kernel_create_data_handle IMPLEMENTATION.
3232

3333
METHOD call.
34-
ASSERT handle IS BOUND.
34+
IF handle IS NOT BOUND.
35+
RAISE EXCEPTION TYPE cx_sy_ref_is_initial.
36+
ENDIF.
3537

3638
WRITE '@KERNEL if (dref.constructor.name === "FieldSymbol") {'.
3739
WRITE '@KERNEL dref = dref.getPointer();'.

Diff for: src/tcp/cl_apc_tcp_client_manager.clas.locals_imp.abap

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ CLASS lcl_client IMPLEMENTATION.
6363
* WRITE '@KERNEL console.dir(data);'.
6464
WRITE '@KERNEL await this.mo_handler.get().if_apc_wsp_event_handler$on_message({i_message: msg});'.
6565
WRITE '@KERNEL });'.
66-
WRITE '@KERNEL this.client.on("end", async () => {this.mo_handler.get().if_apc_wsp_event_handler$on_close();});'.
67-
WRITE '@KERNEL this.client.on("error", async (e) => {this.mo_handler.get().if_apc_wsp_event_handler$on_error();});'.
66+
WRITE '@KERNEL this.client.on("end", async () => {this.mo_handler.get().if_apc_wsp_event_handler$on_close({"i_reason": "connection closed"});});'.
67+
WRITE '@KERNEL this.client.on("error", async (e) => {console.dir("IF_APC_WSP_CLIENT~CONNECT"); console.dir(e); this.mo_handler.get().if_apc_wsp_event_handler$on_error({"i_reason": e.toString()});});'.
6868
WRITE '@KERNEL await new Promise(resolve => this.client.once("connect", resolve));'.
6969
ENDMETHOD.
7070

Diff for: src/tcp/if_apc_wsp_event_handler.intf.abap

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ INTERFACE if_apc_wsp_event_handler PUBLIC.
22
METHODS on_open.
33

44
METHODS on_message
5-
IMPORTING i_message TYPE REF TO if_apc_wsp_message.
5+
IMPORTING
6+
i_message TYPE REF TO if_apc_wsp_message.
67

7-
METHODS on_close.
8+
METHODS on_close
9+
IMPORTING
10+
i_reason TYPE string.
811

912
METHODS on_error
1013
IMPORTING

Diff for: test/cl_apc_tcp_client_manager.clas.testclasses.abap

+30-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ CLASS lcl_handler DEFINITION FINAL.
22
PUBLIC SECTION.
33
INTERFACES if_apc_wsp_event_handler.
44
DATA message TYPE xstring.
5+
DATA error_reason TYPE string.
56
ENDCLASS.
67

78
CLASS lcl_handler IMPLEMENTATION.
@@ -19,7 +20,7 @@ CLASS lcl_handler IMPLEMENTATION.
1920
ENDMETHOD.
2021

2122
METHOD if_apc_wsp_event_handler~on_error.
22-
WRITE / 'on_error'.
23+
error_reason = i_reason.
2324
ENDMETHOD.
2425
ENDCLASS.
2526

@@ -30,6 +31,7 @@ CLASS ltcl_tcp DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION MEDIUM FINAL.
3031

3132
METHODS port_80 FOR TESTING RAISING cx_static_check.
3233
METHODS port_443 FOR TESTING RAISING cx_static_check.
34+
METHODS on_error FOR TESTING RAISING cx_static_check.
3335

3436
ENDCLASS.
3537

@@ -79,4 +81,31 @@ CLASS ltcl_tcp IMPLEMENTATION.
7981
test_port( '443' ).
8082
ENDMETHOD.
8183

84+
METHOD on_error.
85+
86+
DATA lo_handler TYPE REF TO lcl_handler.
87+
DATA li_client TYPE REF TO if_apc_wsp_client.
88+
DATA ls_frame TYPE if_abap_channel_types=>ty_apc_tcp_frame.
89+
DATA li_message_manager TYPE REF TO if_apc_wsp_message_manager.
90+
DATA li_message TYPE REF TO if_apc_wsp_message.
91+
92+
CREATE OBJECT lo_handler.
93+
94+
ls_frame-frame_type = if_apc_tcp_frame_types=>co_frame_type_fixed_length.
95+
ls_frame-fixed_length = 10.
96+
97+
li_client = cl_apc_tcp_client_manager=>create(
98+
i_host = 'somethingerror.org'
99+
i_port = '12345'
100+
i_frame = ls_frame
101+
i_event_handler = lo_handler ).
102+
103+
" li_client->connect( ).
104+
105+
" cl_abap_unit_assert=>assert_equals(
106+
" act = lo_handler->error_reason
107+
" exp = 'todo' ).
108+
109+
ENDMETHOD.
110+
82111
ENDCLASS.

0 commit comments

Comments
 (0)