objects: work around the protected redefinition shortdump (#2891)

The methods CL_OO_CLASS_SECTION_SOURCE=>SCAN_SECTION_SOURCE calls the
function SCAN_ABAP_OBJECTS_SECTION without the parameter superclsname
which causes that variable scan_result (vse_tabs) holds a broken table of
redefinitions for protected methods which leads into a short dump during
CL_OO_CLASS_SECTION_SOURCE=>REVERT_SCAN_RESULTS.

The problem does not occur for public section because the public section
contains "CLASS ... INHERITING FROM ...", so superclsname gets
populated. It's obvious that the class definition statement is not
present in the protected section.

The crash is reported as DBSQL_DUPLICATE_KEY_ERROR in the program
SAPLSEOR at INSERT_REDEFINITIONS.

The code is the following:

    * first refresh db table
        perform delete_redefinitions
          using inhkey.
        delete adjacent duplicates from redefinitions.
    * insert again
        insert seoredef from table redefinitions.

One might think that the delete statement form clears the table seoredef
but the problem is that the variable inhkey contains the super class
name so no redefinitions are actually removed and the insert statement
attempts to insert the redefinitions without parent class again.

The proper solution is to enhance CL_OO_CLASS_SECTION_SOURCE=>SCAN_SECTION_SOURCE
to pass the super class name to SCAN_ABAP_OBJECTS_SECTION - at least for
the protected section.

However, I am not patient and I am not going to wait for the proper fix
(which the maintainers may refuse).
This commit is contained in:
Jakub Filak 2019-10-07 08:18:44 +02:00 committed by Lars Hvam
parent d7e2833483
commit 4c3c4e8ea8

View File

@ -493,9 +493,10 @@ CLASS ZCL_ABAPGIT_OO_CLASS IMPLEMENTATION.
lo_scanner TYPE REF TO cl_oo_source_scanner_class,
lt_methods TYPE cl_oo_source_scanner_class=>type_method_implementations,
lv_method LIKE LINE OF lt_methods,
lt_public TYPE seop_source_string,
lt_auxsrc TYPE seop_source_string,
lt_source TYPE seop_source_string.
"Buffer needs to be refreshed,
"otherwise standard SAP CLIF_SOURCE reorder methods alphabetically
CALL FUNCTION 'SEO_BUFFER_INIT'.
@ -509,15 +510,15 @@ CLASS ZCL_ABAPGIT_OO_CLASS IMPLEMENTATION.
iv_name = is_key-clsname ).
* public
lt_source = lo_scanner->get_public_section_source( ).
IF lt_source IS NOT INITIAL.
lt_public = lo_scanner->get_public_section_source( ).
IF lt_public IS NOT INITIAL.
lv_program = cl_oo_classname_service=>get_pubsec_name( is_key-clsname ).
lv_updated = update_report( iv_program = lv_program
it_source = lt_source ).
it_source = lt_public ).
IF lv_updated = abap_true.
update_meta( iv_name = is_key-clsname
iv_exposure = seoc_exposure_public
it_source = lt_source ).
it_source = lt_public ).
ENDIF.
ENDIF.
@ -528,9 +529,12 @@ CLASS ZCL_ABAPGIT_OO_CLASS IMPLEMENTATION.
lv_updated = update_report( iv_program = lv_program
it_source = lt_source ).
IF lv_updated = abap_true.
lt_auxsrc = lt_public.
APPEND LINES OF lt_source TO lt_auxsrc.
update_meta( iv_name = is_key-clsname
iv_exposure = seoc_exposure_protected
it_source = lt_source ).
it_source = lt_auxsrc ).
ENDIF.
ENDIF.
@ -541,9 +545,12 @@ CLASS ZCL_ABAPGIT_OO_CLASS IMPLEMENTATION.
lv_updated = update_report( iv_program = lv_program
it_source = lt_source ).
IF lv_updated = abap_true.
lt_auxsrc = lt_public.
APPEND LINES OF lt_source TO lt_auxsrc.
update_meta( iv_name = is_key-clsname
iv_exposure = seoc_exposure_private
it_source = lt_source ).
it_source = lt_auxsrc ).
ENDIF.
ENDIF.