Skip to content

tcp + fix exception in CREATE DATA #939

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

Merged
merged 2 commits into from
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"@abaplint/cli": "^2.113.108",
"@abaplint/database-pg": "^2.10.24",
"@abaplint/database-sqlite": "^2.10.24",
"@abaplint/runtime": "^2.10.34",
"@abaplint/transpiler-cli": "^2.10.34",
"@abaplint/runtime": "^2.10.37",
"@abaplint/transpiler-cli": "^2.10.37",
"0x": "^5.8.0"
}
}
4 changes: 3 additions & 1 deletion src/kernel/kernel_create_data_handle.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ ENDCLASS.
CLASS kernel_create_data_handle IMPLEMENTATION.

METHOD call.
ASSERT handle IS BOUND.
IF handle IS NOT BOUND.
RAISE EXCEPTION TYPE cx_sy_ref_is_initial.
ENDIF.

WRITE '@KERNEL if (dref.constructor.name === "FieldSymbol") {'.
WRITE '@KERNEL dref = dref.getPointer();'.
Expand Down
4 changes: 2 additions & 2 deletions src/tcp/cl_apc_tcp_client_manager.clas.locals_imp.abap
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ CLASS lcl_client IMPLEMENTATION.
* WRITE '@KERNEL console.dir(data);'.
WRITE '@KERNEL await this.mo_handler.get().if_apc_wsp_event_handler$on_message({i_message: msg});'.
WRITE '@KERNEL });'.
WRITE '@KERNEL this.client.on("end", async () => {this.mo_handler.get().if_apc_wsp_event_handler$on_close();});'.
WRITE '@KERNEL this.client.on("error", async (e) => {this.mo_handler.get().if_apc_wsp_event_handler$on_error();});'.
WRITE '@KERNEL this.client.on("end", async () => {this.mo_handler.get().if_apc_wsp_event_handler$on_close({"i_reason": "connection closed"});});'.
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()});});'.
WRITE '@KERNEL await new Promise(resolve => this.client.once("connect", resolve));'.
ENDMETHOD.

Expand Down
7 changes: 5 additions & 2 deletions src/tcp/if_apc_wsp_event_handler.intf.abap
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ INTERFACE if_apc_wsp_event_handler PUBLIC.
METHODS on_open.

METHODS on_message
IMPORTING i_message TYPE REF TO if_apc_wsp_message.
IMPORTING
i_message TYPE REF TO if_apc_wsp_message.

METHODS on_close.
METHODS on_close
IMPORTING
i_reason TYPE string.

METHODS on_error
IMPORTING
Expand Down
31 changes: 30 additions & 1 deletion test/cl_apc_tcp_client_manager.clas.testclasses.abap
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ CLASS lcl_handler DEFINITION FINAL.
PUBLIC SECTION.
INTERFACES if_apc_wsp_event_handler.
DATA message TYPE xstring.
DATA error_reason TYPE string.
ENDCLASS.

CLASS lcl_handler IMPLEMENTATION.
Expand All @@ -19,7 +20,7 @@ CLASS lcl_handler IMPLEMENTATION.
ENDMETHOD.

METHOD if_apc_wsp_event_handler~on_error.
WRITE / 'on_error'.
error_reason = i_reason.
ENDMETHOD.
ENDCLASS.

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

METHODS port_80 FOR TESTING RAISING cx_static_check.
METHODS port_443 FOR TESTING RAISING cx_static_check.
METHODS on_error FOR TESTING RAISING cx_static_check.

ENDCLASS.

Expand Down Expand Up @@ -79,4 +81,31 @@ CLASS ltcl_tcp IMPLEMENTATION.
test_port( '443' ).
ENDMETHOD.

METHOD on_error.

DATA lo_handler TYPE REF TO lcl_handler.
DATA li_client TYPE REF TO if_apc_wsp_client.
DATA ls_frame TYPE if_abap_channel_types=>ty_apc_tcp_frame.
DATA li_message_manager TYPE REF TO if_apc_wsp_message_manager.
DATA li_message TYPE REF TO if_apc_wsp_message.

CREATE OBJECT lo_handler.

ls_frame-frame_type = if_apc_tcp_frame_types=>co_frame_type_fixed_length.
ls_frame-fixed_length = 10.

li_client = cl_apc_tcp_client_manager=>create(
i_host = 'somethingerror.org'
i_port = '12345'
i_frame = ls_frame
i_event_handler = lo_handler ).

" li_client->connect( ).

" cl_abap_unit_assert=>assert_equals(
" act = lo_handler->error_reason
" exp = 'todo' ).

ENDMETHOD.

ENDCLASS.