<commit_before>/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.f1x.tools;

import org.f1x.SessionIDBean;
import org.f1x.api.FixVersion;
import org.f1x.api.session.SessionID;
import org.f1x.api.message.MessageBuilder;
import org.f1x.api.message.MessageParser;
import org.f1x.api.message.fields.FixTags;
import org.f1x.api.FixAcceptorSettings;
import org.f1x.v1.FixSessionAcceptor;
import org.f1x.v1.SingleSessionAcceptor;
import org.gflogger.config.xml.XmlLogFactoryConfigurator;

import java.io.IOException;
import java.util.concurrent.TimeUnit;

/** Simple FIX acceptor that echos back all inbound application messages */
public class EchoServer extends SingleSessionAcceptor {

    public EchoServer(int bindPort, SessionID sessionID, FixAcceptorSettings settings) {
        this(null, bindPort, sessionID, settings);
    }

    public EchoServer(String host, int bindPort, SessionID sessionID, FixAcceptorSettings settings) {
        super(host, bindPort, sessionID, new EchoServerSessionAcceptor(FixVersion.FIX44, settings));
    }

    private static class EchoServerSessionAcceptor extends FixSessionAcceptor {
        private final MessageBuilder mb;

        public EchoServerSessionAcceptor(FixVersion fixVersion, FixAcceptorSettings settings) {
            super(fixVersion, settings);
            mb = createMessageBuilder();
        }

        @Override
        protected void processInboundAppMessage(CharSequence msgType, MessageParser parser) throws IOException {
            mb.clear();
            mb.setMessageType(msgType.toString());

            while (parser.next()) {
                int tag = parser.getTagNum();
                if (tag != FixTags.MsgSeqNum) {
                    mb.add(tag, parser.getCharSequenceValue());
                }
            }
            send(mb);
        }
    }

    public static void main (String [] args) throws InterruptedException, IOException {
        try {
            XmlLogFactoryConfigurator.configure("/config/gflogger.xml");
        } catch (Exception e) {
            e.printStackTrace();
        }
        int port = Integer.parseInt(args[0]);
        String host = (args.length > 1) ? args[1] : null;

        LOGGER.info().append("Echo Server : ").append(port).commit();


        FixAcceptorSettings settings = new FixAcceptorSettings();
//        settings.setSocketSendBufferSize(128*1024);
//        settings.setSocketRecvBufferSize(128*1024);
        final EchoServer server = new EchoServer(host, port, new SessionIDBean("SERVER", "CLIENT"), settings);

        final Thread acceptorThread = new Thread(server, "EchoServer");
        acceptorThread.start();

        Runtime.getRuntime().addShutdownHook(new Thread() {
            @Override
            public void run() {
                LOGGER.info().append("Exiting...").commit();
                server.close();
            }
        });
    }
}
<commit_msg>removed comments<commit_after>/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.f1x.tools;

import org.f1x.SessionIDBean;
import org.f1x.api.FixVersion;
import org.f1x.api.session.SessionID;
import org.f1x.api.message.MessageBuilder;
import org.f1x.api.message.MessageParser;
import org.f1x.api.message.fields.FixTags;
import org.f1x.api.FixAcceptorSettings;
import org.f1x.v1.FixSessionAcceptor;
import org.f1x.v1.SingleSessionAcceptor;
import org.gflogger.config.xml.XmlLogFactoryConfigurator;

import java.io.IOException;
import java.util.concurrent.TimeUnit;

/** Simple FIX acceptor that echos back all inbound application messages */
public class EchoServer extends SingleSessionAcceptor {

    public EchoServer(int bindPort, SessionID sessionID, FixAcceptorSettings settings) {
        this(null, bindPort, sessionID, settings);
    }

    public EchoServer(String host, int bindPort, SessionID sessionID, FixAcceptorSettings settings) {
        super(host, bindPort, sessionID, new EchoServerSessionAcceptor(FixVersion.FIX44, settings));
    }

    private static class EchoServerSessionAcceptor extends FixSessionAcceptor {
        private final MessageBuilder mb;

        public EchoServerSessionAcceptor(FixVersion fixVersion, FixAcceptorSettings settings) {
            super(fixVersion, settings);
            mb = createMessageBuilder();
        }

        @Override
        protected void processInboundAppMessage(CharSequence msgType, MessageParser parser) throws IOException {
            mb.clear();
            mb.setMessageType(msgType.toString());

            while (parser.next()) {
                int tag = parser.getTagNum();
                if (tag != FixTags.MsgSeqNum) {
                    mb.add(tag, parser.getCharSequenceValue());
                }
            }
            send(mb);
        }
    }

    public static void main (String [] args) throws InterruptedException, IOException {
        try {
            XmlLogFactoryConfigurator.configure("/config/gflogger.xml");
        } catch (Exception e) {
            e.printStackTrace();
        }
        int port = Integer.parseInt(args[0]);
        String host = (args.length > 1) ? args[1] : null;

        LOGGER.info().append("Echo Server : ").append(port).commit();


        FixAcceptorSettings settings = new FixAcceptorSettings();
        final EchoServer server = new EchoServer(host, port, new SessionIDBean("SERVER", "CLIENT"), settings);

        final Thread acceptorThread = new Thread(server, "EchoServer");
        acceptorThread.start();

        Runtime.getRuntime().addShutdownHook(new Thread() {
            @Override
            public void run() {
                LOGGER.info().append("Exiting...").commit();
                server.close();
            }
        });
    }
}

{'fraction_non_alphanumeric': 0.08696878525761564, 'fraction_numerical': 0.007897705904475368, 'mean_word_length': 3.174646781789639, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 9, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3738045', 'n_tokens_mistral': 2771, 'n_tokens_neox': 2698, 'n_words': 1035}