Before the recombinant plasmid is obtained in recombinant DNA, the gene of interest is condensed with open plasmid by DNA ligase. So what if the length of the gene of interest is not the same to that of the gap of the open plasmid? (e.g. far longer) Can the gene still be connected with the gap or other method are needed to be done before the recombinant plasmid is put back to the bacteria?
From your question I suspect that you are thinking of DNA as being a very rigid molecule — it isn't.
Double stranded DNA is reasonably flexible and a useful mental model would be to think of this as being like tying the ends of two pieces of thin wire together to make a circle.
Double stranded DNA can make a closed circles smaller than 250 bp long1,2 and I don't think there is any known upper limit — for example there is a known circular bacterial chromosome 14,782,125 bp in length3.
A typical plasmid can accommodate inserts of any size up to total size of around 50 kb, but plasmids that are more than 20 kb are very difficult to work with and may require special transformation techniques.
1: Thibault, Thomas et al. “Production of DNA minicircles less than 250 base pairs through a novel concentrated DNA circularization assay enabling minicircle design with NF-κB inhibition activity.” Nucleic acids research vol. 45,5 (2017): e26. doi:10.1093/nar/gkw1034
2: Shore, David, Jorg Langowski, and Robert L. Baldwin. "DNA flexibility studied by covalent closure of short fragments into circles." Proceedings of the National Academy of Sciences 78.8 (1981): 4833-4837