Hungary, Poland, and the Czech Republic broke European Union law by refusing to take in asylum seekers coming to the bloc during the summer of 2015, according to an advisory body to the union's highest court.

The three eastern European countries refused to take in any migrants, citing security concerns and questioned the EU's legal ground for assigning each country a quota of people to take in.

The matter ended up in court with the Advocate General — which advises the European Court of Justice (ECJ) — saying on Thursday that EU law must be followed as well as the bloc's principle of solidarity "necessarily sometimes implies accepting burden-sharing."

Though not obliged to, the ECJ often follows the Advocate General's opinions.

A ruling in the case will take place early next year. The court could fine member countries that violate the law.

This comes as Germany warned of a repeat of the 2015 EU migration crisis — expressing concern over rising migrant arrivals from Turkey.

Responding to the Advocate General's opinion, Polish government spokesman Piotr Muller said that "ensuring security for our citizens is the most important goal of the government's policies. Out actions were dictated by the interests of Polish citizens and the need for protection against uncontrolled migration"

In 2015, more than a million refugees and migrants from the Middle East crossed over to the EU.

The EU tried to introduce quotas to make sharing out asylum-seekers automatic among member states to help southern countries on the Mediterranean where most people arrived.

But vehement opposition by Warsaw, Budapest and others has largely defeated the attempt and, four years on, the bloc is still fighting over how to manage those seeking shelter from the wars in the Middle East or poverty and conflicts in Africa.