Jump to content

Sonjli

Members
  • Content Count

    110
  • Joined

  • Last visited

Posts posted by Sonjli


  1. 9 minutes ago, Cristian Peța said:

    Comp is captured and I can confirm debugger evaluator is not working.

    Declare LComp: TADOQuery in anonymous method and assign LComp := Comp. Then it will work to evaluate LComp....

    Ok, thanks. I needed a confirmation.

    Same exact behaviour is for inline variables inside anon method... no way to evaluate them during debug.

    It's frustrating if you are working with Spring4d or other modern libraries.


  2. Hello,

    I hope to be in the right place.

    Also, I don't find this behaviour in forum neither in embt quality.

     

    I am in debug with a breakpoint inside an anon method and when I try to evaluate a variable (CTRL + F7, mouse over, watches, etc. ) I get a "undeclared identifier" if I use a class field.

     

    Example:

     

    TmyDM = class(TDataModule)
    	Comp: TADOQuery;
        ...
    end;
    
    ...
    
    procedure ...blabla...;
    var
    	CompForDebug: TADOQuery;
    begin
        Comp.Close;
        Comp.Parameters.ParamByName('test').Value := 100;
        Comp.Open; // <-- Here evaluate "Comp". I get the right thing
    	FmyList.ForEach(
        	procedure(const obj: IMyThing)
            var
            	CompForDebugLocal: TADOQuery;
            begin
            	Comp.Close;
                Comp.Parameters.ParamByName('test').Value := 100;
                Comp.Open; // <-- Here evaluate "Comp". I get "Undeclared identifier"
                
                // This doesn't work:
                CompForDebugLocal := Comp; 
            	CompForDebugLocal.Close;
                CompForDebugLocal.Parameters.ParamByName('test').Value := 100;
                CompForDebugLocal.Open; // <-- Here evaluate "Comp". I get "Undeclared identifier"
                
                // This doesn't work:
                CompForDebug := Comp; 
            	CompForDebug.Close;
                CompForDebug.Parameters.ParamByName('test').Value := 100;
                CompForDebug.Open; // <-- Here evaluate "Comp". I get the right thing
                
            end
        );
    end;

     


  3. On 8/8/2024 at 5:58 PM, Remy Lebeau said:

    Did you try capturing and comparing the raw HTTP requests that THTTPClient and TIdHTTP are generating to see what is different between them?

    Non for now. Can you recommend me a simple sniffer? (wireshark is too much for me...)

    Or is there any other way to capture the raw request?


  4. 7 hours ago, Remy Lebeau said:

    Can you be more specific

    I am using keycloak for oauth2. The POST to retrieve the jwt token works perfectly with indy in linux container. Keycloak gives me a "java.lang.StringIndexOutOfBoundsException" when I use THttpClient.

    If I compile under Windows and do the POST from windows to keycloak both works.

    7 hours ago, Remy Lebeau said:

    Yes. What does that have to do with the issue?

    If I compile my app for Linux: Indy works, THttpClient doesn't work

    If I compile my app for Windows: Indy works, THttpClient works


  5. Hello,

    I found an issue using the rtl THTTPClient.Post method in Linux.

    If I use a windows client that makes the post to Linux server, all working like a charm.

    If I use a linux client (paserver via docker container) the post works but the server doesn't understand tha call.

    If I use TIdHTTP instead, all keep working like a charm.

    Any idea about this?

    Isn't the standard RTL completely cross platform?


  6. On 7/8/2024 at 7:41 PM, ertank said:

    If your concern is high memory usage, you can try OXml and use SAX parser. If your data is well structured, you can also use Delphi classes together with SAX parsing. This would dramatically reduce memory consumption compared to System.JSON.

    http://www.kluug.net/oxml.php

     

    However, your problem is not clear as stated earlier. You might want to add details.

    Sorry, you're right. Mine is JSON data and still compressed, not XML. Thanks!


  7. On 7/8/2024 at 4:20 PM, corneliusdavid said:

    Is this a one-time input of historical data or is more data available from the API every day? Perhaps it makes sense to write a completely separate program that operates in the background and just pulls data into a local database on a regular basis and then your user-facing program interacts with the local database?

    Thanks. Another good one. Small sqlite db loaded with "batch night", yes.


  8. On 7/8/2024 at 3:36 PM, Lars Fosdal said:

    Do you get a monolithic collection of json elements for the entire day, or do they arrive one by one?

    If monolithic, you could split it up and add each element to a queue.


    Is there a sequence of processing requirement?

    If not, you could have multiple parallell consumers of that queue.

    Hi. It is a monolithic json. Parallel consumers can be an option (one day per task, for example), yes. I have to plan correct boundaries (day, week, etc.), but yes, good one.


  9. Hello,

    I have to use an external (horrible... 🤮) REST api that gives me a lot of data. In one case I have over 60.000 json records by day, so for one year it starts from 60k x 365. And the customer need all that data.

    For now I work day by day, but it is not an option.

    I would like to "stream" the data coming from webservice and use an async thread to "eat" the json while streaming. How can I get it in Delphi? Is it possible?

    (Other ideas are welcome! :classic_ninja:)

     

    Thanks!


  10. Hello,

    I have two strange issues when closing IDE.

    The first: IDE closes but it persist in memory so I have to kill the process

    image.thumb.png.6367b9ea09e2db4fa40ebe5cd1eab475.png

    The second: The IDE closes but one or two of exceptions come to life

    image.thumb.png.b1de2768f73dec3c70b3f23ed578d895.png

     

    I have a lot of experts installed and I know for sure these problems are for this cause.

    So, I tried to remove them one by one and open\close the IDE. I tried in various combinations. A lot of loss time. Every time a different behaviour.

    The problem seems to be very random. If I have none of the experts installed, issues go away as if they never existed

     

    I don't want THE solution, I understand.

     

    My question is: is there any tool (logger, external debugger, etc.) to try to catch the problem?

     

    Thanks


  11. 50 minutes ago, Stefan Glienke said:

    Nice, never heard of it before but I enjoy looking at libraries that have Spring as their dependency :classic_cool:  I submitted some improvement suggestions in the area we discussed here.

    Very strange you never heard about FidoLib: the best library after the invention of programming (and Sprign4d, for sure :classic_tongue:)

    jokes apart, Thanks for your help!

    • Haha 1

  12. 5 minutes ago, Stefan Glienke said:

    It is because the compiler does not keep typeinfo of types that are only used as generic parameters in generic types in the public typeinfo list (which is what FindType with a qualified name iterates).

    If you had included the code for that Unmarshal I could probably give more advice on how to implement it best given that you seem to have support for spring collections in there

    Yes. The code is in FidoLib (I collaborate in the project).

    The file is this: https://github.com/mirko-bianco/FidoLib/blob/develop/source/Json/Fido.JSON.Marshalling.pas

    • Like 1

  13. 16 hours ago, Stefan Glienke said:

    Why look up the type by full-qualified name in the first place? Every spring collection has the ElementType property that returns a PTypeInfo.

    This was not the point, for me. I just would like to know why the RTTI doesn't know nothing about IScarafuglio until it is declared.

    Anyway I am looking for the use of that prop in my code.


  14. Hello. In this source

    unit Unit2;
    
    interface
    
    uses
      Winapi.Windows,
      Winapi.Messages,
      System.SysUtils,
      System.Variants,
      System.Classes,
      Vcl.Graphics,
      Vcl.Controls,
      Vcl.Forms,
      Vcl.Dialogs,
      Vcl.StdCtrls,
      Spring.Collections;
    
    type
      IScarafuglio = interface(IInvokable)
        ['{8E5CC1F0-8759-4965-BF83-0C2DC5E1153C}']
        function Nome: string;
        function cognome: string;
        function Eta: Integer;
      end;
    
      IPippo = interface(IInvokable)
        ['{C6B11B79-F08C-47D0-9E21-EBE4788E43E1}']
        function PlutoList: IReadOnlyList<IScarafuglio>;
      end;
    
      TForm2 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    
    implementation
    
    {$R *.dfm}
    
    procedure TForm2.Button1Click(Sender: TObject);
    var
      a: IPippo;
    begin
      // Use the RTTI in Unmarshal
      a := Unmarshal<IPippo>(
        '''
        {
          "PlutoList": [
            {
            "Nome": "Eddy",
            "cognome": "Mazzarini",
            "Eta": 22
            },
            {
            "Nome": "Luca",
            "cognome": "Vecchiato",
            "Eta": 56
            }
          ]
        }
        '''
        );
    
      ShowMessage(a.PlutoList[1].Nome); // AV because IScarafuglio instance is nil
    end;
    
    end.

    the interface IScarafuglio is never found with

    Context.FindType('Unit2.IScarafuglio');

    The result i always nil.

    But if I add a simple field or anything else that reference the IScarafuglio in interface, then everything is fine:

     

    unit Unit2;
    
    interface
    
    uses
      Winapi.Windows,
      Winapi.Messages,
      System.SysUtils,
      System.Variants,
      System.Classes,
      Vcl.Graphics,
      Vcl.Controls,
      Vcl.Forms,
      Vcl.Dialogs,
      Vcl.StdCtrls,
      Spring.Collections;
    
    type
      IScarafuglio = interface(IInvokable)
        ['{8E5CC1F0-8759-4965-BF83-0C2DC5E1153C}']
        function Nome: string;
        function cognome: string;
        function Eta: Integer;
      end;
    
      IPippo = interface(IInvokable)
        ['{C6B11B79-F08C-47D0-9E21-EBE4788E43E1}']
        function PlutoList: IReadOnlyList<IScarafuglio>;
      end;
    
      TForm2 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
        XYZ: IScarafuglio; // From now everything is fine and RTTI "know" who IScarafuglio is... 
      public
        { Public declarations }
      end;
    
    implementation
    
    {$R *.dfm}
    
    procedure TForm2.Button1Click(Sender: TObject);
    var
      a: IPippo;
    begin
      // Use the RTTI in Unmarshal
      a := Unmarshal<IPippo>(
        '''
        {
          "PlutoList": [
            {
            "Nome": "Eddy",
            "cognome": "Mazzarini",
            "Eta": 22
            },
            {
            "Nome": "Luca",
            "cognome": "Vecchiato",
            "Eta": 56
            }
          ]
        }
        '''
        );
    
      ShowMessage(a.PlutoList[1].Nome); // WORKING!!!
    end;
    
    end.

    Why this behaviour?

     

    Thanks

×